Package org.apache.camel.dataformat.csv
Class CsvMarshaller
java.lang.Object
org.apache.camel.dataformat.csv.CsvMarshaller
This class marshal data into a CSV format.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CsvMarshaller
create
(org.apache.commons.csv.CSVFormat format, CsvDataFormat dataFormat) Creates a new instance.protected org.apache.commons.csv.CSVPrinter
createPrinter
(org.apache.camel.Exchange exchange, OutputStream outputStream) Creates and returns aCSVPrinter
.protected abstract Iterable
<?> getMapRecordValues
(Map<?, ?> map) Gets the CSV record values of the given map.void
marshal
(org.apache.camel.Exchange exchange, Object object, OutputStream outputStream) Marshals the given object into the given stream.
-
Constructor Details
-
CsvMarshaller
protected CsvMarshaller(org.apache.commons.csv.CSVFormat format)
-
-
Method Details
-
create
public static CsvMarshaller create(org.apache.commons.csv.CSVFormat format, CsvDataFormat dataFormat) Creates a new instance.- Parameters:
format
- CSV formatdataFormat
- Camel CSV data format- Returns:
- New instance
-
marshal
public void marshal(org.apache.camel.Exchange exchange, Object object, OutputStream outputStream) throws org.apache.camel.NoTypeConversionAvailableException, IOException Marshals the given object into the given stream.- Parameters:
exchange
- Exchange (used for access to type conversion)object
- Body to marshaloutputStream
- Output stream of the CSV- Throws:
org.apache.camel.NoTypeConversionAvailableException
- if the body cannot be convertedIOException
- if we cannot write into the given stream
-
createPrinter
protected org.apache.commons.csv.CSVPrinter createPrinter(org.apache.camel.Exchange exchange, OutputStream outputStream) throws IOException Creates and returns aCSVPrinter
.- Parameters:
exchange
- Exchange (used for access to type conversion). Could NOT benull
.outputStream
- Output stream of the CSV. Could NOT benull
.- Returns:
- a new
CSVPrinter
. Nevernull
. - Throws:
IOException
-
getMapRecordValues
Gets the CSV record values of the given map.- Parameters:
map
- Input map- Returns:
- CSV record values of the given map
-