// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package routing.demo.supp;

import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;

import routing.demo.convert.ConvertXML2CSV;

public class XML2CSV implements Processor {
    private char delim;
    private char quote;
    public XML2CSV(char delim, char quote) {
        super();
        this.delim = delim;
        this.quote = quote;
    }
    @Override
    public void process(Exchange exchange) throws Exception {
        Message msg = exchange.getMessage();
        String xml = msg.getBody(String.class);
        String csv = ConvertXML2CSV.convert(xml, delim, quote);
        msg.setBody(csv);
    }
}
