com.github.sourcegroove.batch.item.file.excel.ExcelRowMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-batch-file-layout Show documentation
Show all versions of spring-batch-file-layout Show documentation
Layout driven spring batch item readers and writers
package com.github.sourcegroove.batch.item.file.excel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.validation.BindException;
import java.util.List;
public class ExcelRowMapper {
protected final Log log = LogFactory.getLog(getClass());
private ExcelRowTokenizer rowTokenizer;
private FieldSetMapper fieldSetMapper;
public void setRowTokenizer(ExcelRowTokenizer rowTokenizer) {
this.rowTokenizer = rowTokenizer;
}
public void setFieldSetMapper(FieldSetMapper fieldSetMapper) {
this.fieldSetMapper = fieldSetMapper;
}
public T mapRow(List row, int rowNumber) {
log.trace("Mapping row " + rowNumber + " with " + row.size() + " values");
FieldSet fieldSet = this.rowTokenizer.tokenize(row, rowNumber);
try {
return this.fieldSetMapper.mapFieldSet(fieldSet);
} catch (BindException e) {
throw new RuntimeException("Error mapping fieldset at row " + rowNumber, e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy