Class PatternMatchingCompositeLineMapper<T>
- java.lang.Object
- org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper<T>
- All Implemented Interfaces:
LineMapper<T>,org.springframework.beans.factory.InitializingBean
public class PatternMatchingCompositeLineMapper<T> extends java.lang.Object implements LineMapper<T>, org.springframework.beans.factory.InitializingBean
A
LineMapperimplementation that stores a mapping of String patterns to delegateLineTokenizers as well as a mapping of String patterns to delegateFieldSetMappers. 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
- See Also:
PatternMatchingCompositeLineTokenizer
Constructor Summary
Constructors Constructor Description PatternMatchingCompositeLineMapper()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()TmapLine(java.lang.String line, int lineNumber)Implementations must implement this method to map the provided line to the parameter type T.voidsetFieldSetMappers(java.util.Map<java.lang.String,FieldSetMapper<T>> fieldSetMappers)voidsetTokenizers(java.util.Map<java.lang.String,LineTokenizer> tokenizers)
Method Detail
mapLine
public T mapLine(java.lang.String line, int lineNumber) throws java.lang.Exception
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:
java.lang.Exception- if error occurred while parsing.
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.Exception
setTokenizers
public void setTokenizers(java.util.Map<java.lang.String,LineTokenizer> tokenizers)
setFieldSetMappers
public void setFieldSetMappers(java.util.Map<java.lang.String,FieldSetMapper<T>> fieldSetMappers)