public interface ICsvDozerBeanWriter extends ICsvWriter
Modifier and Type | Method and Description |
---|---|
void |
configureBeanMapping(Class<?> clazz,
String[] fieldMapping)
Configures the underlying DozerBeanMapper with the mappings required to map from the specified class to the CSV
file (this method may only be called before writing, as it's not possible to configure a DozerBeanMapper that has
already been initialized).
|
void |
write(Object source)
Writes the fields of the object as columns of a CSV file, using the pre-configured DozerBeanMapper to map fields
to the appropriate columns.
|
void |
write(Object source,
CellProcessor[] processors)
Writes the fields of the object as columns of a CSV file, using the pre-configured DozerBeanMapper to map fields
to the appropriate columns.
|
getLineNumber, getRowNumber, writeComment, writeHeader
void configureBeanMapping(Class<?> clazz, String[] fieldMapping)
Each element of the fieldMapping array represents a CSV column to be written 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 (cannot contain null elements)NullPointerException
- if clazz or fieldMapping (or one of its elements) is nullvoid write(Object source) throws IOException
source
- the object (bean instance) containing the values to writeIOException
- if an I/O error occurredMappingException
- if there was an exception during Dozer mappingNullPointerException
- if source is nullSuperCsvException
- if there was a general exception while writingvoid write(Object source, CellProcessor[] processors) throws IOException
Before writing, the data can be further processed by cell processors (each element in the processors array corresponds with a CSV column). A null entry in the processors array indicates no further processing is required (the value returned by toString() will be written as the column value). toString() will be called on each (processed) element prior to writing.
source
- the object (bean instance) containing the values to writeprocessors
- an array of CellProcessors used to further process data before it is written (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 value returned by
toString() will be written as the column value).IOException
- if an I/O error occurredMappingException
- if there was an exception during Dozer mappingNullPointerException
- if source, nameMapping or processors are nullSuperCsvConstraintViolationException
- if a CellProcessor constraint failedSuperCsvException
- if there was a general exception while writing/processingCopyright © 2007–2015 Super CSV. All rights reserved.