类 FlatFileItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder<T>
public class FlatFileItemReaderBuilder<T> extends java.lang.Object
A builder implementation for theFlatFileItemReader.- 从以下版本开始:
- 4.0
- 作者:
- Michael Minella, Glenn Renfro, Mahmoud Ben Hassine
- 另请参阅:
FlatFileItemReader
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classFlatFileItemReaderBuilder.DelimitedBuilder<T>A builder for constructing aDelimitedLineTokenizerstatic classFlatFileItemReaderBuilder.FixedLengthBuilder<T>A builder for constructing aFixedLengthTokenizer
字段概要
字段 修饰符和类型 字段 说明 protected org.apache.commons.logging.Loglogger
构造器概要
构造器 构造器 说明 FlatFileItemReaderBuilder()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 FlatFileItemReaderBuilder<T>addComment(java.lang.String comment)Add a string to the list of Strings that indicate commented lines.FlatFileItemReaderBuilder<T>beanFactory(org.springframework.beans.factory.BeanFactory beanFactory)Configures theBeanFactoryused to create the beans that are returned as items.FlatFileItemReaderBuilder<T>beanMapperStrict(boolean beanMapperStrict)If set to true, mapping will fail if theFieldSetcontains fields that cannot be mapped to the bean.FlatFileItemReader<T>build()Builds theFlatFileItemReader.FlatFileItemReaderBuilder<T>comments(java.lang.String... comments)Set an array of Strings that indicate lines that are comments (and therefore skipped by the reader).FlatFileItemReaderBuilder<T>currentItemCount(int currentItemCount)Index for the current item.FlatFileItemReaderBuilder<T>customEditors(java.util.Map<java.lang.Class<?>,java.beans.PropertyEditor> customEditors)Register custom type converters for beans being mapped.FlatFileItemReaderBuilder.DelimitedBuilder<T>delimited()Returns an instance of aFlatFileItemReaderBuilder.DelimitedBuilderfor building aDelimitedLineTokenizer.FlatFileItemReaderBuilder<T>distanceLimit(int distanceLimit)Configures the maximum tolerance between the actual spelling of a field's name and the property's name.FlatFileItemReaderBuilder<T>encoding(java.lang.String encoding)Configure the encoding used by the reader to read the input source.FlatFileItemReaderBuilder<T>fieldSetMapper(FieldSetMapper<T> mapper)AFieldSetMapperimplementation to be used.FlatFileItemReaderBuilder.FixedLengthBuilder<T>fixedLength()Returns an instance of aFlatFileItemReaderBuilder.FixedLengthBuilderfor building aFixedLengthTokenizer.FlatFileItemReaderBuilder<T>lineMapper(LineMapper<T> lineMapper)ALineMapperimplementation to be used.FlatFileItemReaderBuilder<T>linesToSkip(int linesToSkip)The number of lines to skip at the beginning of reading the file.FlatFileItemReaderBuilder<T>lineTokenizer(LineTokenizer tokenizer)ALineTokenizerimplementation to be used.FlatFileItemReaderBuilder<T>maxItemCount(int maxItemCount)Configure the max number of items to be read.FlatFileItemReaderBuilder<T>name(java.lang.String name)The name used to calculate the key within theExecutionContext.FlatFileItemReaderBuilder<T>prototypeBeanName(java.lang.String prototypeBeanName)Configures the id of a prototype scoped bean to be used as the item returned by the reader.FlatFileItemReaderBuilder<T>recordSeparatorPolicy(RecordSeparatorPolicy policy)Configure a customRecordSeparatorPolicyfor the reader.FlatFileItemReaderBuilder<T>resource(org.springframework.core.io.Resource resource)TheResourceto be used as input.FlatFileItemReaderBuilder<T>saveState(boolean saveState)Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.FlatFileItemReaderBuilder<T>skippedLinesCallback(LineCallbackHandler callback)A callback to be called for each line that is skipped.FlatFileItemReaderBuilder<T>strict(boolean strict)Configure if the reader should be in strict mode (require the inputResourceto exist).FlatFileItemReaderBuilder<T>targetType(java.lang.Class<? extends T> targetType)The class that will represent the "item" to be returned from the reader.
字段详细资料
logger
protected org.apache.commons.logging.Log logger
构造器详细资料
FlatFileItemReaderBuilder
public FlatFileItemReaderBuilder()
方法详细资料
saveState
public FlatFileItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- 参数:
saveState- defaults to true- 返回:
- The current instance of the builder.
name
public FlatFileItemReaderBuilder<T> name(java.lang.String name)
The name used to calculate the key within theExecutionContext. Required ifsaveState(boolean)is set to true.- 参数:
name- name of the reader instance- 返回:
- The current instance of the builder.
- 另请参阅:
ItemStreamSupport.setName(String)
maxItemCount
public FlatFileItemReaderBuilder<T> maxItemCount(int maxItemCount)
Configure the max number of items to be read.- 参数:
maxItemCount- the max items to be read- 返回:
- The current instance of the builder.
- 另请参阅:
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
currentItemCount
public FlatFileItemReaderBuilder<T> currentItemCount(int currentItemCount)
Index for the current item. Used on restarts to indicate where to start from.- 参数:
currentItemCount- current index- 返回:
- this instance for method chaining
- 另请参阅:
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
addComment
public FlatFileItemReaderBuilder<T> addComment(java.lang.String comment)
Add a string to the list of Strings that indicate commented lines. Defaults toFlatFileItemReader.DEFAULT_COMMENT_PREFIXES.- 参数:
comment- the string to define a commented line.- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setComments(String[])
comments
public FlatFileItemReaderBuilder<T> comments(java.lang.String... comments)
Set an array of Strings that indicate lines that are comments (and therefore skipped by the reader). This method overrides the default comment prefixes which areFlatFileItemReader.DEFAULT_COMMENT_PREFIXES.- 参数:
comments- an array of strings to identify comments.- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setComments(String[])
recordSeparatorPolicy
public FlatFileItemReaderBuilder<T> recordSeparatorPolicy(RecordSeparatorPolicy policy)
Configure a customRecordSeparatorPolicyfor the reader.- 参数:
policy- custom policy- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setRecordSeparatorPolicy(RecordSeparatorPolicy)
resource
public FlatFileItemReaderBuilder<T> resource(org.springframework.core.io.Resource resource)
TheResourceto be used as input.- 参数:
resource- the input to the reader.- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setResource(Resource)
strict
public FlatFileItemReaderBuilder<T> strict(boolean strict)
Configure if the reader should be in strict mode (require the inputResourceto exist).- 参数:
strict- true if the input file is required to exist.- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setStrict(boolean)
encoding
public FlatFileItemReaderBuilder<T> encoding(java.lang.String encoding)
Configure the encoding used by the reader to read the input source. Default value isFlatFileItemReader.DEFAULT_CHARSET.- 参数:
encoding- to use to read the input source.- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setEncoding(String)
linesToSkip
public FlatFileItemReaderBuilder<T> linesToSkip(int linesToSkip)
The number of lines to skip at the beginning of reading the file.- 参数:
linesToSkip- number of lines to be skipped.- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setLinesToSkip(int)
skippedLinesCallback
public FlatFileItemReaderBuilder<T> skippedLinesCallback(LineCallbackHandler callback)
A callback to be called for each line that is skipped.- 参数:
callback- the callback- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setSkippedLinesCallback(LineCallbackHandler)
lineMapper
public FlatFileItemReaderBuilder<T> lineMapper(LineMapper<T> lineMapper)
ALineMapperimplementation to be used.- 参数:
lineMapper-LineMapper- 返回:
- The current instance of the builder.
- 另请参阅:
FlatFileItemReader.setLineMapper(LineMapper)
fieldSetMapper
public FlatFileItemReaderBuilder<T> fieldSetMapper(FieldSetMapper<T> mapper)
AFieldSetMapperimplementation to be used.- 参数:
mapper- aFieldSetMapper- 返回:
- The current instance of the builder.
- 另请参阅:
DefaultLineMapper.setFieldSetMapper(FieldSetMapper)
lineTokenizer
public FlatFileItemReaderBuilder<T> lineTokenizer(LineTokenizer tokenizer)
ALineTokenizerimplementation to be used.- 参数:
tokenizer- aLineTokenizer- 返回:
- The current instance of the builder.
- 另请参阅:
DefaultLineMapper.setLineTokenizer(LineTokenizer)
delimited
public FlatFileItemReaderBuilder.DelimitedBuilder<T> delimited()
Returns an instance of aFlatFileItemReaderBuilder.DelimitedBuilderfor building aDelimitedLineTokenizer. TheDelimitedLineTokenizerconfigured by this builder will only be used if one is not explicitly configured vialineTokenizer
fixedLength
public FlatFileItemReaderBuilder.FixedLengthBuilder<T> fixedLength()
Returns an instance of aFlatFileItemReaderBuilder.FixedLengthBuilderfor building aFixedLengthTokenizer. TheFixedLengthTokenizerconfigured by this builder will only be used if thelineTokenizerhas not been configured.
targetType
public FlatFileItemReaderBuilder<T> targetType(java.lang.Class<? extends T> targetType)
The class that will represent the "item" to be returned from the reader. This class is used via theBeanWrapperFieldSetMapper. If more complex logic is required, providing your ownFieldSetMapperviafieldSetMapperis required.- 参数:
targetType- The class to map to- 返回:
- The current instance of the builder.
- 另请参阅:
BeanWrapperFieldSetMapper.setTargetType(Class)
prototypeBeanName
public FlatFileItemReaderBuilder<T> prototypeBeanName(java.lang.String prototypeBeanName)
Configures the id of a prototype scoped bean to be used as the item returned by the reader.- 参数:
prototypeBeanName- the name of a prototype scoped bean- 返回:
- The current instance of the builder.
- 另请参阅:
BeanWrapperFieldSetMapper.setPrototypeBeanName(String)
beanFactory
public FlatFileItemReaderBuilder<T> beanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
Configures theBeanFactoryused to create the beans that are returned as items.- 参数:
beanFactory- aBeanFactory- 返回:
- The current instance of the builder.
- 另请参阅:
BeanWrapperFieldSetMapper.setBeanFactory(BeanFactory)
customEditors
public FlatFileItemReaderBuilder<T> customEditors(java.util.Map<java.lang.Class<?>,java.beans.PropertyEditor> customEditors)
Register custom type converters for beans being mapped.- 参数:
customEditors- aMapof editors- 返回:
- The current instance of the builder.
- 另请参阅:
BeanWrapperFieldSetMapper.setCustomEditors(Map)
distanceLimit
public FlatFileItemReaderBuilder<T> distanceLimit(int distanceLimit)
Configures the maximum tolerance between the actual spelling of a field's name and the property's name.- 参数:
distanceLimit- distance limit to set- 返回:
- The current instance of the builder.
- 另请参阅:
BeanWrapperFieldSetMapper.setDistanceLimit(int)
beanMapperStrict
public FlatFileItemReaderBuilder<T> beanMapperStrict(boolean beanMapperStrict)
If set to true, mapping will fail if theFieldSetcontains fields that cannot be mapped to the bean.- 参数:
beanMapperStrict- defaults to false- 返回:
- The current instance of the builder.
- 另请参阅:
BeanWrapperFieldSetMapper.setStrict(boolean)
build
public FlatFileItemReader<T> build()
Builds theFlatFileItemReader.- 返回:
- a
FlatFileItemReader