public class CsvBeanReader extends AbstractCsvReader implements ICsvBeanReader
Constructor and Description |
---|
CsvBeanReader(ITokenizer tokenizer,
CsvPreference preferences)
Constructs a new CsvBeanReader with the supplied (custom) Tokenizer and CSV preferences.
|
CsvBeanReader(Reader reader,
CsvPreference preferences)
Constructs a new CsvBeanReader with the supplied Reader and CSV preferences.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
read(Class<T> clazz,
String... nameMapping)
Reads a row of a CSV file and populates an instance of the specified class, using the supplied name mapping to
map column values to the appropriate fields.
|
<T> T |
read(Class<T> clazz,
String[] nameMapping,
CellProcessor... processors)
Reads a row of a CSV file and populates an instance of the specified class, using the supplied name mapping to
map column values to the appropriate fields.
|
<T> T |
read(T bean,
String... nameMapping)
Reads a row of a CSV file and populates the bean, using the supplied name mapping to map column values to the
appropriate fields.
|
<T> T |
read(T bean,
String[] nameMapping,
CellProcessor... processors)
Reads a row of a CSV file and populates the bean, using the supplied name mapping to map column values to the
appropriate fields.
|
close, executeProcessors, get, getColumns, getHeader, getLineNumber, getPreferences, getRowNumber, getUntokenizedRow, length, readRow
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
get, getHeader, getLineNumber, getRowNumber, getUntokenizedRow, length
public CsvBeanReader(Reader reader, CsvPreference preferences)
reader
- the readerpreferences
- the CSV preferencesNullPointerException
- if reader or preferences are nullpublic CsvBeanReader(ITokenizer tokenizer, CsvPreference preferences)
tokenizer
- the tokenizerpreferences
- the CSV preferencesNullPointerException
- if tokenizer or preferences are nullpublic <T> T read(Class<T> clazz, String... nameMapping) throws IOException
read
in interface ICsvBeanReader
T
- the bean typeclazz
- the type to instantiate. If the type is a class then a new instance will be created using the default
no-args constructor. If the type is an interface, a proxy object which implements the interface will
be created instead.nameMapping
- an array of Strings linking the CSV columns to their corresponding field in the bean (the array length
should match the number of columns). A null entry in the array indicates that the column
should be ignored (the field in the bean will be null - or its default value).IOException
- if an I/O error occurredpublic <T> T read(Class<T> clazz, String[] nameMapping, CellProcessor... processors) throws IOException
read
in interface ICsvBeanReader
T
- the bean typeclazz
- the type to instantiate. If the type is a class then a new instance will be created using the default
no-args constructor. If the type is an interface, a proxy object which implements the interface will
be created instead.nameMapping
- an array of Strings linking the CSV columns to their corresponding field in the bean (the array length
should match the number of columns). A null entry in the array indicates that the column
should be ignored (the field in the bean will be null - or its default value).processors
- an array of CellProcessors used to further process data before it is populated on the bean (each
element in the processors array corresponds with a CSV column - the number of processors should match
the number of columns). A null entry indicates no further processing is required (the
unprocessed String value will be set on the bean's field).IOException
- if an I/O error occurredpublic <T> T read(T bean, String... nameMapping) throws IOException
read
in interface ICsvBeanReader
T
- the bean typebean
- the bean to populatenameMapping
- an array of Strings linking the CSV columns to their corresponding field in the bean (the array length
should match the number of columns). A null entry in the array indicates that the column
should be ignored (the field in the bean will be null - or its default value).IOException
- if an I/O error occurredpublic <T> T read(T bean, String[] nameMapping, CellProcessor... processors) throws IOException
read
in interface ICsvBeanReader
T
- the bean typebean
- the bean to populatenameMapping
- an array of Strings linking the CSV columns to their corresponding field in the bean (the array length
should match the number of columns). A null entry in the array indicates that the column
should be ignored (the field in the bean will be null - or its default value).processors
- an array of CellProcessors used to further process data before it is populated on the bean (each
element in the processors array corresponds with a CSV column - the number of processors should match
the number of columns). A null entry indicates no further processing is required (the
unprocessed String value will be set on the bean's field).IOException
- if an I/O error occurredCopyright © 2007–2015 Super CSV. All rights reserved.