Class FixedLengthTokenizer
java.lang.Object
org.springframework.batch.infrastructure.item.file.transform.AbstractLineTokenizer
org.springframework.batch.infrastructure.item.file.transform.FixedLengthTokenizer
- All Implemented Interfaces:
LineTokenizer
Tokenizer used to process data obtained from files with fixed-length format. Columns
are specified by array of Range objects (
setColumns(Range[]) ).- Author:
- tomas.slanina, peter.zozom, Dave Syer, Lucas Ward, Michael Minella, Mahmoud Ben Hassine, Stefano Cordio
-
Field Summary
Fields inherited from class AbstractLineTokenizer
names -
Constructor Summary
ConstructorsConstructorDescriptionFixedLengthTokenizer(Range... ranges) Create a newFixedLengthTokenizerinstance with the given ranges. -
Method Summary
Modifier and TypeMethodDescriptiondoTokenize(String line) Yields the tokens resulting from the splitting of the suppliedline.voidsetColumns(Range... ranges) Set the column ranges.Methods inherited from class AbstractLineTokenizer
hasNames, isStrict, setFieldSetFactory, setNames, setStrict, tokenize
-
Constructor Details
-
FixedLengthTokenizer
Create a newFixedLengthTokenizerinstance with the given ranges.- Parameters:
ranges- the column ranges expected in the input- Since:
- 6.0
-
-
Method Details
-
setColumns
Set the column ranges. Used in conjunction with theRangeArrayPropertyEditorthis property can be set in the form of a String describing the range boundaries, e.g. "1,4,7" or "1-3,4-6,7" or "1-2,4-5,7-10". If the last range is open then the rest of the line is read into that column (irrespective of the strict flag setting).- Parameters:
ranges- the column ranges expected in the input- See Also:
-
doTokenize
Yields the tokens resulting from the splitting of the suppliedline.- Specified by:
doTokenizein classAbstractLineTokenizer- Parameters:
line- the line to be tokenized (can benull)- Returns:
- the resulting tokens (empty if the line is null)
- Throws:
IncorrectLineLengthException- if line length is greater than or less than the max range set.
-