public void marshal(Exchange exchange, Object object, OutputStream outputStream) throws Exception {
Map map = ExchangeHelper.convertToMandatoryType(exchange, Map.class, object);
OutputStreamWriter out = new OutputStreamWriter(outputStream);
try {
CSVConfig conf = createConfig();
// lets add fields
Set set = map.keySet();
for (Object value : set) {
if (value != null) {
String text = value.toString();
CSVField field = new CSVField(text);
conf.addField(field);
}
}
CSVWriter writer = new CSVWriter(conf);
writer.setWriter(out);
writer.writeRecord(map);