Hi,
I would like to know if someone has an example showing how to map the
content of a CSV file to a POJO using inside this POJO class @annotation ?
For the moment, I use ArrayList + iterator (see code hereafter) to achieve
the extraction of the content but I'm sure that I can simplify my code using
@Annotation
E.g. :
Camel route
from("file:///c:/temp/test?noop=true")
.unmarshal().csv()
.to("bean:converter?methodName=TransformMessage");
Converter class
public void TransformMessage(Exchange in) {
process(in.getIn().getBody(List.class));
}
@SuppressWarnings("unchecked")
private void process(List messages) {
// Iterate through the list of messages
for (Iterator<ArrayList> it = messages.iterator();
it.hasNext();) {
// Split the content of the message into field
message = it.next();
field = (String[]) message.toArray();
order = new Order();
order.setId(Integer.valueOf(field[0]).intValue());
order.setBank(field[1]);
order.setAmountFrom(Double.parseDouble(field[2]));
order.setAmountTo(Double.parseDouble(field[3]));
order.setOrderInstruction(field[4].trim());
this.orderService.createOrder(order);
}
}
Regards,
Charles
--
View this message in context:
http://www.nabble.com/Map-content-of-CSV-file-to-POJO-using-%40Annotation-%21%21-tp16296721s22882p16296721.html
Sent from the Camel - Users mailing list archive at Nabble.com.