public interface ICsvDozerBeanReader extends ICsvReader
Modifier and Type | Method and Description |
---|---|
void |
configureBeanMapping(Class<?> clazz,
String[] fieldMapping)
Configures the underlying DozerBeanMapper with the mappings required to map from the CSV file to the specified
class (this method may only be called before reading, as it's not possible to configure a DozerBeanMapper that
has already been initialized).
|
void |
configureBeanMapping(Class<?> clazz,
String[] fieldMapping,
Class<?>[] hintTypes)
Configures the underlying DozerBeanMapper with the mappings required to map from the CSV file to the specified
class (this method may only be called before reading, as it's not possible to configure a DozerBeanMapper that
has already been initialized).
|
<T> T |
read(Class<T> clazz)
Reads a row of a CSV file and populates an instance of the specified class, using Dozer to map column values to
the appropriate fields.
|
<T> T |
read(Class<T> clazz,
CellProcessor... processors)
Reads a row of a CSV file and populates an instance of the specified class, using Dozer to map column values to
the appropriate fields.
|
<T> T |
read(T bean)
Reads a row of a CSV file and populates the supplied bean, using Dozer to map column values to the appropriate
fields.
|
<T> T |
read(T bean,
CellProcessor... processors)
Reads a row of a CSV file and populates the supplied bean, using Dozer to map column values to the appropriate
fields.
|
get, getHeader, getLineNumber, getRowNumber, getUntokenizedRow, length
void configureBeanMapping(Class<?> clazz, String[] fieldMapping)
Each element of the fieldMapping array represents a CSV column to be read and uses the standard Dozer field mapping syntax. For example, if you were configuring the mappings for Person class you might define firstName as the first element (just a simple field mapping), address.city as the second element (a nested - or deep - field mapping), and accounts[0].balance as the third element (index based mapping).
If you require access to the other features of Dozer in your mappings (customer getters/setters, bean factories, custom converters), then you should supply your own DozerBeanMapper to the Writer instead.
clazz
- the class to add mapping configuration for (same as the type passed into write methods)fieldMapping
- the field mapping for for each column (may contain null elements to indicate ignored columns)NullPointerException
- if clazz or fieldMapping is nullvoid configureBeanMapping(Class<?> clazz, String[] fieldMapping, Class<?>[] hintTypes)
Each element of the fieldMapping array represents a CSV column to be read and uses the standard Dozer field mapping syntax. For example, if you were configuring the mappings for Person class you might define firstName as the first element (just a simple field mapping), address.city as the second element (a nested - or deep - field mapping), and accounts[0].balance as the third element (index based mapping).
If you are mapping to an indexed list element (e.g. accounts[0]) and using a cell processor to return a custom bean type (e.g. a ParseAccount processor that creates an Account bean), you will need to specify a hint for that column so Dozer can map that column.
If you require access to the other features of Dozer in your mappings (customer getters/setters, bean factories, custom converters), then you should supply your own DozerBeanMapper to the Writer instead.
clazz
- the class to add mapping configuration for (same as the type passed into write methods)fieldMapping
- the field mapping for for each column (may contain null elements to indicate ignored columns)hintTypes
- an array of types used as hints for Dozer when mapping to an indexed list element (e.g.
accounts[0]) - a null element indicates no hint is required for that columnNullPointerException
- if clazz, fieldMapping, or hintTypes is nullIllegalArgumentException
- if fieldMapping.length != hintTypes.length<T> T read(Class<T> clazz) throws IOException
T
- the bean typeclazz
- the type to instantiateIOException
- if an I/O error occurredMappingException
- if there was an exception during Dozer mappingNullPointerException
- if clazz is nullSuperCsvException
- if there was a general exception while reading/processing<T> T read(T bean) throws IOException
T
- the bean typebean
- the bean to populateIOException
- if an I/O error occurredMappingException
- if there was an exception during Dozer mappingNullPointerException
- if bean is nullSuperCsvException
- if there was a general exception while reading/processing<T> T read(Class<T> clazz, CellProcessor... processors) throws IOException
T
- the bean typeclazz
- the type to instantiateprocessors
- the cell processorsIOException
- if an I/O error occurredMappingException
- if there was an exception during Dozer mappingNullPointerException
- if clazz is nullSuperCsvException
- if there was a general exception while reading/processing<T> T read(T bean, CellProcessor... processors) throws IOException
T
- the bean typebean
- the bean to populateprocessors
- the cell processorsIOException
- if an I/O error occurredMappingException
- if there was an exception during Dozer mappingNullPointerException
- if bean is nullSuperCsvException
- if there was a general exception while reading/processingCopyright © 2007–2015 Super CSV. All rights reserved.