public class MappingLdifReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements ResourceAwareItemReaderItemStream<T>, org.springframework.beans.factory.InitializingBean
MappingLdifReader
is an adaptation of the FlatFileItemReader
built around an LdifParser
. It differs from the standard LdifReader
in its ability to map
LdapAttributes
objects to POJOs.
The MappingLdifReader
requires an RecordMapper
implementation. If mapping
is not required, the LdifReader
should be used instead. It simply returns an LdapAttributes
object which can be consumed and manipulated as necessary by ItemProcessor
or any
output service.
As with the FlatFileItemReader
, the strict
option
differentiates between whether or not to require the resource to exist before processing. In the case of a value set to false, a warning
is logged instead of an exception being thrown.
Constructor and Description |
---|
MappingLdifReader() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected void |
doClose()
Close the resources opened in
AbstractItemCountingItemStreamItemReader.doOpen() . |
protected void |
doOpen()
Open resources necessary to start reading input.
|
protected T |
doRead()
Read next item from input.
|
void |
setRecordMapper(RecordMapper<T> recordMapper)
Setter for object mapper.
|
void |
setRecordsToSkip(int recordsToSkip)
Public setter for the number of lines to skip at the start of a file.
|
void |
setResource(org.springframework.core.io.Resource resource) |
void |
setSkippedRecordsCallback(RecordCallbackHandler skippedRecordsCallback)
RecordCallbackHandler implementations can be used to take action on skipped records. |
void |
setStrict(boolean strict)
In strict mode the reader will throw an exception on
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext) if the
input resource does not exist. |
close, getCurrentItemCount, isSaveState, jumpToItem, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
getExecutionContextKey, setExecutionContextName, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, open, update
read
public void setStrict(boolean strict)
AbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
if the
input resource does not exist.strict
- false by defaultpublic void setSkippedRecordsCallback(RecordCallbackHandler skippedRecordsCallback)
RecordCallbackHandler
implementations can be used to take action on skipped records.skippedRecordsCallback
- will be called for each one of the initial
skipped lines before any items are read.public void setRecordsToSkip(int recordsToSkip)
recordsToSkip
- the number of lines to skippublic void setRecordMapper(RecordMapper<T> recordMapper)
recordMapper
- maps record to an objectprotected void doClose() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
AbstractItemCountingItemStreamItemReader.doOpen()
.doClose
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected void doOpen() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
doOpen
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkprotected T doRead() throws java.lang.Exception
AbstractItemCountingItemStreamItemReader
doRead
in class AbstractItemCountingItemStreamItemReader<T>
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the frameworkpublic void setResource(org.springframework.core.io.Resource resource)
setResource
in interface ResourceAwareItemReaderItemStream<T>
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception