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
-
Method Summary
Modifier and TypeMethodDescriptionList ofString
values used to indicate what records are comments.int
Provides the index of the current item.TheString
used to divide the record into fields.Returns the encoding for the input file.AList
of indices indicating what fields to include.int
Number of lines to skip when reading the input file.int
The maximum number of items to be read.getName()
Returns the configured value of the name used to calculateExecutionContext
keys.String[]
getNames()
Names of each column.char
The char used to indicate that a field is quoted.The column ranges to be used to parsed a fixed width file.org.springframework.core.io.Resource
The input file for theFlatFileItemReader
.boolean
Indicates if the input file is a delimited file or not.boolean
Indicates that a file contains records with fixed length columns.boolean
Indicates if the number of tokens must match the number of configured fields.boolean
Returns the configured value of if the state of the reader will be persisted.boolean
isStrict()
Returns true if a missing input file is considered an error.void
setComments
(List<String> comments) Takes a list ofString
elements used to indicate what records are comments.void
setCurrentItemCount
(int currentItemCount) Index for the current item.void
setDelimited
(boolean delimited) Indicates that aDelimitedLineTokenizer
should be used to parse each line.void
setDelimiter
(String delimiter) Define the delimiter for the file.void
setEncoding
(String encoding) Configure the encoding used by the reader to read the input source.void
setFixedLength
(boolean fixedLength) Indicates that aFixedLengthTokenizer
should be used to parse the records in the file.void
setIncludedFields
(List<Integer> includedFields) A list of indices of the fields within a delimited file to be included.void
setLinesToSkip
(int linesToSkip) The number of lines to skip at the beginning of reading the file.void
setMaxItemCount
(int maxItemCount) Configure the max number of items to be read.void
The name used to calculate the key within theExecutionContext
.void
The names of the fields to be parsed from the file.void
setParsingStrict
(boolean parsingStrict) Indicates if the number of tokens must match the number of configured fields.void
setQuoteCharacter
(char quoteCharacter) Define the character used to quote fields.void
Column ranges for each field.void
setResource
(org.springframework.core.io.Resource resource) TheResource
to be used as input.void
setSaveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.void
setStrict
(boolean strict) Configure if the reader should be in strict mode (require the inputResource
to 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 theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true
-
getName
Returns the configured value of the name used to calculateExecutionContext
keys.- 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 ofString
values used to indicate what records are comments.- Returns:
- list of comment indicators
-
setComments
Takes a list ofString
elements 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) TheResource
to 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 inputResource
to 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 aDelimitedLineTokenizer
should be used to parse each line.- Parameters:
delimited
- true if the file is a delimited file
-
getDelimiter
TheString
used 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
AList
of 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 aFixedLengthTokenizer
should 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
Range
instances
-
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
-