类 LdifReader
- java.lang.Object
- org.springframework.batch.item.ItemStreamSupport
- org.springframework.batch.item.support.AbstractItemStreamItemReader<T>
- org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<org.springframework.ldap.core.LdapAttributes>
- org.springframework.batch.item.ldif.LdifReader
- 所有已实现的接口:
ResourceAwareItemReaderItemStream<org.springframework.ldap.core.LdapAttributes>
,ItemReader<org.springframework.ldap.core.LdapAttributes>
,ItemStream
,ItemStreamReader<org.springframework.ldap.core.LdapAttributes>
,org.springframework.beans.factory.InitializingBean
public class LdifReader extends AbstractItemCountingItemStreamItemReader<org.springframework.ldap.core.LdapAttributes> implements ResourceAwareItemReaderItemStream<org.springframework.ldap.core.LdapAttributes>, org.springframework.beans.factory.InitializingBean
TheLdifReader
is an adaptation of theFlatFileItemReader
built around anLdifParser
.Unlike the
FlatFileItemReader
, theLdifReader
does not require a mapper. Instead, this version of theLdifReader
simply returns anLdapAttributes
object which can be consumed and manipulated as necessary byItemProcessor
or any output service. Alternatively, theRecordMapper
interface can be implemented and set in aMappingLdifReader
to map records to objects for return.LdifReader
usage is mimics that of theFlatFileItemReader
for all intensive purposes. Adjustments have been made to process records instead of lines, however. As such, therecordsToSkip
attribute indicates the number of records from the top of the file that should not be processed. Implementations of theRecordCallbackHandler
interface can be used to execute operations on those skipped records.As with the
FlatFileItemReader
, thestrict
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.- 作者:
- Keith Barlow
构造器概要
构造器 构造器 说明 LdifReader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
protected void
doClose()
Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen()
.protected void
doOpen()
Open resources necessary to start reading input.protected org.springframework.ldap.core.LdapAttributes
doRead()
Read next item from input.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)
Establishes the resource that will be used as the input for the LdifReader.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 onAbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
if the input resource does not exist.从类继承的方法 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader
close, getCurrentItemCount, isSaveState, jumpToItem, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
从类继承的方法 org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, setExecutionContextName, setName
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.batch.item.ItemReader
read
从接口继承的方法 org.springframework.batch.item.ItemStream
close, open, update
构造器详细资料
LdifReader
public LdifReader()
方法详细资料
setStrict
public void setStrict(boolean strict)
In strict mode the reader will throw an exception onAbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
if the input resource does not exist.- 参数:
strict
- true by default
setSkippedRecordsCallback
public 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.
setRecordsToSkip
public void setRecordsToSkip(int recordsToSkip)
Public setter for the number of lines to skip at the start of a file. Can be used if the file contains a header without useful (column name) information, and without a comment delimiter at the beginning of the lines.- 参数:
recordsToSkip
- the number of lines to skip
doClose
protected void doClose() throws java.lang.Exception
Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen()
.- 指定者:
doClose
在类中AbstractItemCountingItemStreamItemReader<org.springframework.ldap.core.LdapAttributes>
- 抛出:
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
doOpen
protected void doOpen() throws java.lang.Exception
Open resources necessary to start reading input.- 指定者:
doOpen
在类中AbstractItemCountingItemStreamItemReader<org.springframework.ldap.core.LdapAttributes>
- 抛出:
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
doRead
protected org.springframework.ldap.core.LdapAttributes doRead() throws java.lang.Exception
Read next item from input.- 指定者:
doRead
在类中AbstractItemCountingItemStreamItemReader<org.springframework.ldap.core.LdapAttributes>
- 返回:
- an item or
null
if the data source is exhausted - 抛出:
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
setResource
public void setResource(org.springframework.core.io.Resource resource)
Establishes the resource that will be used as the input for the LdifReader.- 指定者:
setResource
在接口中ResourceAwareItemReaderItemStream<org.springframework.ldap.core.LdapAttributes>
- 参数:
resource
- the resource that will be read.
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
- 指定者:
afterPropertiesSet
在接口中org.springframework.beans.factory.InitializingBean
- 抛出:
java.lang.Exception