Class FlatFileItemReaderProperties
java.lang.Object
org.springframework.cloud.task.batch.autoconfigure.flatfile.FlatFileItemReaderProperties
@ConfigurationProperties(prefix="spring.batch.job.flatfileitemreader")
public class FlatFileItemReaderProperties
extends Object
Properties to configure a
FlatFileItemReader.- Since:
- 2.3
- Author:
- Michael Minella
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList ofStringvalues used to indicate what records are comments.intProvides the index of the current item.TheStringused to divide the record into fields.Returns the encoding for the input file.AListof indices indicating what fields to include.intNumber of lines to skip when reading the input file.intThe maximum number of items to be read.getName()Returns the configured value of the name used to calculateExecutionContextkeys.String[]getNames()Names of each column.charThe char used to indicate that a field is quoted.List<org.springframework.batch.item.file.transform.Range>The column ranges to be used to parsed a fixed width file.org.springframework.core.io.ResourceThe input file for theFlatFileItemReader.booleanIndicates if the input file is a delimited file or not.booleanIndicates that a file contains records with fixed length columns.booleanIndicates if the number of tokens must match the number of configured fields.booleanReturns the configured value of if the state of the reader will be persisted.booleanisStrict()Returns true if a missing input file is considered an error.voidsetComments(List<String> comments) Takes a list ofStringelements used to indicate what records are comments.voidsetCurrentItemCount(int currentItemCount) Index for the current item.voidsetDelimited(boolean delimited) Indicates that aDelimitedLineTokenizershould be used to parse each line.voidsetDelimiter(String delimiter) Define the delimiter for the file.voidsetEncoding(String encoding) Configure the encoding used by the reader to read the input source.voidsetFixedLength(boolean fixedLength) Indicates that aFixedLengthTokenizershould be used to parse the records in the file.voidsetIncludedFields(List<Integer> includedFields) A list of indices of the fields within a delimited file to be included.voidsetLinesToSkip(int linesToSkip) The number of lines to skip at the beginning of reading the file.voidsetMaxItemCount(int maxItemCount) Configure the max number of items to be read.voidThe name used to calculate the key within theExecutionContext.voidThe names of the fields to be parsed from the file.voidsetParsingStrict(boolean parsingStrict) Indicates if the number of tokens must match the number of configured fields.voidsetQuoteCharacter(char quoteCharacter) Define the character used to quote fields.voidColumn ranges for each field.voidsetResource(org.springframework.core.io.Resource resource) TheResourceto be used as input.voidsetSaveState(boolean saveState) Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.voidsetStrict(boolean strict) Configure if the reader should be in strict mode (require the inputResourceto exist).
-
Constructor Details
-
FlatFileItemReaderProperties
public FlatFileItemReaderProperties()
-
-
Method Details
-
isSaveState
public boolean isSaveState()Returns the configured value of if the state of the reader will be persisted.- Returns:
- true if the state will be persisted
-
setSaveState
public void setSaveState(boolean saveState) Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Parameters:
saveState- defaults to true
-
getName
Returns the configured value of the name used to calculateExecutionContextkeys.- Returns:
- the name
-
setName
The name used to calculate the key within theExecutionContext. Required ifsetSaveState(boolean)is set to true.- Parameters:
name- name of the reader instance- See Also:
-
ItemStreamSupport.setName(String)
-
getMaxItemCount
public int getMaxItemCount()The maximum number of items to be read.- Returns:
- the configured number of items, defaults to Integer.MAX_VALUE
-
setMaxItemCount
public void setMaxItemCount(int maxItemCount) Configure the max number of items to be read.- Parameters:
maxItemCount- the max items to be read- See Also:
-
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
-
getCurrentItemCount
public int getCurrentItemCount()Provides the index of the current item.- Returns:
- item index
-
setCurrentItemCount
public void setCurrentItemCount(int currentItemCount) Index for the current item. Also used on restarts to indicate where to start from.- Parameters:
currentItemCount- current index- See Also:
-
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
-
getComments
List ofStringvalues used to indicate what records are comments.- Returns:
- list of comment indicators
-
setComments
Takes a list ofStringelements used to indicate what records are comments.- Parameters:
comments- strings used to indicate commented lines
-
getResource
public org.springframework.core.io.Resource getResource()The input file for theFlatFileItemReader.- Returns:
- a Resource
-
setResource
public void setResource(org.springframework.core.io.Resource resource) TheResourceto be used as input.- Parameters:
resource- the input to the reader.- See Also:
-
FlatFileItemReader.setResource(Resource)
-
isStrict
public boolean isStrict()Returns true if a missing input file is considered an error.- Returns:
- true if the input file is required.
-
setStrict
public void setStrict(boolean strict) Configure if the reader should be in strict mode (require the inputResourceto exist).- Parameters:
strict- true if the input file is required to exist.- See Also:
-
FlatFileItemReader.setStrict(boolean)
-
getEncoding
Returns the encoding for the input file. Defaults toFlatFileItemReader#DEFAULT_CHARSET.- Returns:
- the configured encoding
-
setEncoding
Configure the encoding used by the reader to read the input source. Default value isFlatFileItemReader.DEFAULT_CHARSET.- Parameters:
encoding- to use to read the input source.- See Also:
-
FlatFileItemReader.setEncoding(String)
-
getLinesToSkip
public int getLinesToSkip()Number of lines to skip when reading the input file.- Returns:
- number of lines
-
setLinesToSkip
public void setLinesToSkip(int linesToSkip) The number of lines to skip at the beginning of reading the file.- Parameters:
linesToSkip- number of lines to be skipped.- See Also:
-
FlatFileItemReader.setLinesToSkip(int)
-
isDelimited
public boolean isDelimited()Indicates if the input file is a delimited file or not.- Returns:
- true if the file is delimited
-
setDelimited
public void setDelimited(boolean delimited) Indicates that aDelimitedLineTokenizershould be used to parse each line.- Parameters:
delimited- true if the file is a delimited file
-
getDelimiter
TheStringused to divide the record into fields.- Returns:
- the delimiter
-
setDelimiter
Define the delimiter for the file.- Parameters:
delimiter- String used as a delimiter between fields.- See Also:
-
DelimitedLineTokenizer.setDelimiter(String)
-
getQuoteCharacter
public char getQuoteCharacter()The char used to indicate that a field is quoted.- Returns:
- the quote char
-
setQuoteCharacter
public void setQuoteCharacter(char quoteCharacter) Define the character used to quote fields.- Parameters:
quoteCharacter- char used to define quoted fields- See Also:
-
DelimitedLineTokenizer.setQuoteCharacter(char)
-
getIncludedFields
AListof indices indicating what fields to include.- Returns:
- list of indices
-
setIncludedFields
A list of indices of the fields within a delimited file to be included.- Parameters:
includedFields- indices of the fields- See Also:
-
DelimitedLineTokenizer.setIncludedFields(int[])
-
isFixedLength
public boolean isFixedLength()Indicates that a file contains records with fixed length columns.- Returns:
- true if the file is parsed using column indices
-
setFixedLength
public void setFixedLength(boolean fixedLength) Indicates that aFixedLengthTokenizershould be used to parse the records in the file.- Parameters:
fixedLength- true if the records should be tokenized by column index
-
getRanges
The column ranges to be used to parsed a fixed width file.- Returns:
- a list of
Rangeinstances
-
setRanges
Column ranges for each field.- Parameters:
ranges- list of ranges in start-end format (end is optional)
-
getNames
Names of each column.- Returns:
- names
-
setNames
The names of the fields to be parsed from the file.- Parameters:
names- names of fields
-
isParsingStrict
public boolean isParsingStrict()Indicates if the number of tokens must match the number of configured fields.- Returns:
- true if they must match
-
setParsingStrict
public void setParsingStrict(boolean parsingStrict) Indicates if the number of tokens must match the number of configured fields.- Parameters:
parsingStrict- true if they must match
-