Package org.apache.camel.dataformat.csv
Class CsvMarshaller
- java.lang.Object
-
- org.apache.camel.dataformat.csv.CsvMarshaller
-
public abstract class CsvMarshaller extends Object
This class marshal data into a CSV format.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCsvMarshaller(org.apache.commons.csv.CSVFormat format)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static CsvMarshallercreate(org.apache.commons.csv.CSVFormat format, CsvDataFormat dataFormat)Creates a new instance.protected org.apache.commons.csv.CSVPrintercreatePrinter(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.voidmarshal(org.apache.camel.Exchange exchange, Object object, OutputStream outputStream)Marshals the given object into the given stream.
-
-
-
Method Detail
-
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, IOExceptionMarshals 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 IOExceptionCreates 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
-
-