Class PatternMatchingCompositeLineMapper<T>
java.lang.Object
org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper<T>
- All Implemented Interfaces:
LineMapper<T>
A LineMapper implementation that stores a mapping of String patterns to
delegate LineTokenizers as well as a mapping of String patterns to delegate
FieldSetMappers. Each line received will be tokenized and then mapped to a
field set.
Both the tokenizing and the mapping work in a similar way. The line will be checked for its matching pattern. If the key matches a pattern in the map of delegates, then the corresponding delegate will be used. Patterns are sorted starting with the most specific, and the first match succeeds.
- Since:
- 2.0
- Author:
- Dan Garrette, Dave Syer, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPatternMatchingCompositeLineMapper(Map<String, LineTokenizer> tokenizers, Map<String, FieldSetMapper<T>> fieldSetMappers) Construct aPatternMatchingCompositeLineMapperwith the provided maps of tokenizers and field set mappers. -
Method Summary
Modifier and TypeMethodDescriptionImplementations must implement this method to map the provided line to the parameter type T.voidsetFieldSetMappers(Map<String, FieldSetMapper<T>> fieldSetMappers) voidsetTokenizers(Map<String, LineTokenizer> tokenizers)
-
Constructor Details
-
PatternMatchingCompositeLineMapper
public PatternMatchingCompositeLineMapper(Map<String, LineTokenizer> tokenizers, Map<String, FieldSetMapper<T>> fieldSetMappers) Construct aPatternMatchingCompositeLineMapperwith the provided maps of tokenizers and field set mappers. Both maps must be non-empty.- Parameters:
tokenizers- the map of patterns to tokenizersfieldSetMappers- the map of patterns to field set mappers- Since:
- 6.0
-
-
Method Details
-
mapLine
Description copied from interface:LineMapperImplementations must implement this method to map the provided line to the parameter type T. The line number represents the number of lines into a file the current line resides.- Specified by:
mapLinein interfaceLineMapper<T>- Parameters:
line- to be mappedlineNumber- of the current line- Returns:
- mapped object of type T
- Throws:
Exception- if error occurred while parsing.
-
setTokenizers
-
setFieldSetMappers
-