org.apache.camel.dataformat.csv
Class CsvDataFormat

java.lang.Object
  extended by org.apache.camel.dataformat.csv.CsvDataFormat
All Implemented Interfaces:
DataFormat

public class CsvDataFormat
extends Object
implements DataFormat

CSV Data format.

By default, columns are autogenerated in the resulting CSV. Subsequent messages use the previously created columns with new fields being added at the end of the line. Thus, field order is the same from message to message. Autogeneration can be disabled. In this case, only the fields defined in csvConfig are written on the output.

Version:
$Revision: 20034 $

Constructor Summary
CsvDataFormat()
           
 
Method Summary
 org.apache.commons.csv.writer.CSVConfig getConfig()
           
 String getDelimiter()
           
 org.apache.commons.csv.CSVStrategy getStrategy()
           
 boolean isAutogenColumns()
           
 void marshal(Exchange exchange, Object object, OutputStream outputStream)
          Marshals the object to the given Stream.
 void setAutogenColumns(boolean autogenColumns)
          Auto generate columns.
 void setConfig(org.apache.commons.csv.writer.CSVConfig config)
           
 void setDelimiter(String delimiter)
           
 void setStrategy(org.apache.commons.csv.CSVStrategy strategy)
           
 Object unmarshal(Exchange exchange, InputStream inputStream)
          Unmarshals the given stream into an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CsvDataFormat

public CsvDataFormat()
Method Detail

marshal

public void marshal(Exchange exchange,
                    Object object,
                    OutputStream outputStream)
             throws Exception
Description copied from interface: DataFormat
Marshals the object to the given Stream.

Specified by:
marshal in interface DataFormat
Parameters:
exchange - the current exchange
object - the object to be marshalled
outputStream - the output stream to write the marshalled result to
Throws:
Exception - can be thrown

unmarshal

public Object unmarshal(Exchange exchange,
                        InputStream inputStream)
                 throws Exception
Description copied from interface: DataFormat
Unmarshals the given stream into an object.

Notice: The result is set as body on the exchange OUT message. It is possible to mutate the OUT message provided in the given exchange parameter. For instance adding headers to the OUT message will be preserved.

Specified by:
unmarshal in interface DataFormat
Parameters:
exchange - the current exchange
inputStream - the input stream with the object to be unmarshalled
Returns:
the unmarshalled object
Throws:
Exception - can be thrown

getDelimiter

public String getDelimiter()

setDelimiter

public void setDelimiter(String delimiter)

getConfig

public org.apache.commons.csv.writer.CSVConfig getConfig()

setConfig

public void setConfig(org.apache.commons.csv.writer.CSVConfig config)

getStrategy

public org.apache.commons.csv.CSVStrategy getStrategy()

setStrategy

public void setStrategy(org.apache.commons.csv.CSVStrategy strategy)

isAutogenColumns

public boolean isAutogenColumns()

setAutogenColumns

public void setAutogenColumns(boolean autogenColumns)
Auto generate columns.

Parameters:
autogenColumns - set to false to disallow column autogeneration (default true)


Apache CAMEL