T
- Type of object you are converting the data to.public interface MappingStrategy<T>
Modifier and Type | Method and Description |
---|---|
void |
captureHeader(CSVReader reader)
Implementation of this method can grab the header line before parsing
begins to use to map columns to bean properties.
|
T |
createBean()
Implementation will return a bean of the type of object you are mapping.
|
PropertyDescriptor |
findDescriptor(int col)
Gets the property descriptor for a given column position.
|
BeanField |
findField(int col)
Gets the field for a given column position.
|
int |
findMaxFieldIndex()
Finds and returns the highest index in this mapping.
|
String[] |
generateHeader()
Implementations of this method must return an array of column headers
based on the contents of the mapping strategy.
|
Integer |
getColumnIndex(String name)
Gets the column index that corresponds to a specific column name.
|
boolean |
isAnnotationDriven()
Determines whether the mapping strategy is driven by annotations.
|
void |
registerBeginningOfRecordForReading()
Indicate to the mapping strategy that we are beginning to read a new
record.
|
void |
registerEndOfRecordForReading()
Must be called at the end of input for a line/record to verify that the
line was complete.
|
PropertyDescriptor findDescriptor(int col) throws IntrospectionException
col
- The column to find the description forIntrospectionException
- Thrown on error retrieving the property
description.BeanField findField(int col) throws CsvBadConverterException
registerBeginningOfRecordForReading()
, this method also marks
the field indicated as having been present in the input.col
- The column to find the field forCsvBadConverterException
- If a custom converter for a field cannot
be initializedint findMaxFieldIndex()
findField(int)
will return null for these columns, so we need
a way to know when to stop writing new columns.T createBean() throws InstantiationException, IllegalAccessException
InstantiationException
- Thrown on error creating object.IllegalAccessException
- Thrown on error creating object.void captureHeader(CSVReader reader) throws IOException, CsvRequiredFieldEmptyException
reader
- The CSVReader to use for header parsingIOException
- If parsing failsCsvRequiredFieldEmptyException
- If a field is required, but the
header or column position for the field is not present in the inputString[] generateHeader()
Integer getColumnIndex(String name)
name
- The column nameboolean isAnnotationDriven()
void registerBeginningOfRecordForReading()
void registerEndOfRecordForReading() throws CsvRequiredFieldEmptyException
CsvRequiredFieldEmptyException
- If a required column is missingCopyright © 2017. All rights reserved.