public class CsvBeanWriter extends AbstractCsvWriter implements ICsvBeanWriter
Constructor and Description |
---|
CsvBeanWriter(java.io.Writer writer,
CsvPreference preference)
Constructs a new CsvBeanWriter with the supplied Writer and CSV preferences.
|
Modifier and Type | Method and Description |
---|---|
void |
write(java.lang.Object source,
java.lang.String... nameMapping)
Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the
appropriate columns.
|
void |
write(java.lang.Object source,
java.lang.String[] nameMapping,
CellProcessor[] processors)
Writes the fields of the object as columns of a CSV file, using the supplied name mapping to map fields to the
appropriate columns.
|
close, escapeString, flush, getLineNumber, getRowNumber, incrementRowAndLineNo, writeComment, writeHeader, writeRow, writeRow, writeRow
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLineNumber, getRowNumber, writeComment, writeHeader
public CsvBeanWriter(java.io.Writer writer, CsvPreference preference)
writer
- the writerpreference
- the CSV preferencesjava.lang.NullPointerException
- if writer or preference are nullpublic void write(java.lang.Object source, java.lang.String... nameMapping) throws java.io.IOException
write
in interface ICsvBeanWriter
source
- the object (bean instance) containing the values to writenameMapping
- an array of Strings linking the fields in the bean to their corresponding CSV columns (the array
length should match the number of columns). A null entry in the array indicates that the
column should be ignored (the column will be empty).java.io.IOException
- if an I/O error occurredpublic void write(java.lang.Object source, java.lang.String[] nameMapping, CellProcessor[] processors) throws java.io.IOException
write
in interface ICsvBeanWriter
source
- the object (bean instance) containing the values to writenameMapping
- an array of Strings linking the fields in the bean to their corresponding CSV columns (the array
length should match the number of columns). A null entry in the array indicates that the
column should be ignored (the column will be empty).processors
- 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).java.io.IOException
- if an I/O error occurredCopyright © 2007-2014 Super CSV. All Rights Reserved.