RESOLVED - issue BATCH-640: FieldSetMapper.mapLine() should contain the line number
This commit is contained in:
@@ -276,7 +276,7 @@ public class FlatFileItemReader extends AbstractBufferedItemReaderItemStream imp
|
||||
int lineCount = getReader().getPosition();
|
||||
try {
|
||||
FieldSet tokenizedLine = tokenizer.tokenize(line);
|
||||
return fieldSetMapper.mapLine(tokenizedLine);
|
||||
return fieldSetMapper.mapLine(tokenizedLine, lineCount);
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
// add current line count to message and re-throw
|
||||
|
||||
@@ -102,7 +102,7 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar im
|
||||
|
||||
/**
|
||||
* The bean name (id) for an object that can be populated from the field set
|
||||
* that will be passed into {@link #mapLine(FieldSet)}. Typically a
|
||||
* that will be passed into {@link #mapLine(FieldSet, int)}. Typically a
|
||||
* prototype scoped bean so that a new instance is returned for each field
|
||||
* set mapped.
|
||||
*
|
||||
@@ -118,7 +118,7 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar im
|
||||
/**
|
||||
* Public setter for the type of bean to create instead of using a prototype
|
||||
* bean. An object of this type will be created from its default constructor
|
||||
* for every call to {@link #mapLine(FieldSet)}.<br/>
|
||||
* for every call to {@link #mapLine(FieldSet, int)}.<br/>
|
||||
*
|
||||
* Either this property or the prototype bean name must be specified, but
|
||||
* not both.
|
||||
@@ -153,10 +153,10 @@ public class BeanWrapperFieldSetMapper extends DefaultPropertyEditorRegistrar im
|
||||
* the {@link DataBinder} from {@link #createBinder(Object)} has errors
|
||||
* after binding).
|
||||
*
|
||||
* @see org.springframework.batch.item.file.mapping.FieldSetMapper#mapLine(org.springframework.batch.item.file.mapping.FieldSet)
|
||||
* @see org.springframework.batch.item.file.mapping.FieldSetMapper#mapLine(org.springframework.batch.item.file.mapping.FieldSet, int)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object mapLine(FieldSet fs) {
|
||||
public Object mapLine(FieldSet fs, int lineNum) {
|
||||
Object copy = getBean();
|
||||
DataBinder binder = createBinder(copy);
|
||||
binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties())));
|
||||
|
||||
@@ -30,6 +30,7 @@ public interface FieldSetMapper {
|
||||
* Method used to map data obtained from a {@link FieldSet} into an object.
|
||||
*
|
||||
* @param fs the {@link FieldSet} to map
|
||||
* @param lineNum the current line number (if known), or negative if not
|
||||
*/
|
||||
public Object mapLine(FieldSet fs);
|
||||
public Object mapLine(FieldSet fs, int lineNum);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class PassThroughFieldSetMapper implements FieldSetMapper, FieldSetCreato
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.file.FieldSetMapper#mapLine(org.springframework.batch.io.file.FieldSet)
|
||||
*/
|
||||
public Object mapLine(FieldSet fs) {
|
||||
public Object mapLine(FieldSet fs, int lineNum) {
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user