Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 55ACF104F0 for ; Thu, 17 Apr 2014 23:43:56 +0000 (UTC) Received: (qmail 50364 invoked by uid 500); 17 Apr 2014 23:43:34 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 50315 invoked by uid 500); 17 Apr 2014 23:43:30 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 50288 invoked by uid 99); 17 Apr 2014 23:43:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Apr 2014 23:43:27 +0000 X-ASF-Spam-Status: No, hits=0.6 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.223.180 as permitted sender) Received: from [209.85.223.180] (HELO mail-ie0-f180.google.com) (209.85.223.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Apr 2014 23:43:24 +0000 Received: by mail-ie0-f180.google.com with SMTP id as1so1045784iec.39 for ; Thu, 17 Apr 2014 16:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=L2NXp59o1i69YgVzuENAPFZLbt+ZaA2/WEcnstJhzsc=; b=v7bqfuB8yPGlC6Ag70xCx61e9qoIv/myoGsqT5qI/DqZpIFl49P2x8p+5nRc/dhACL 2qoBOTMDM0ak1ImlETIWuVX/attb33iglETdfoz/ko7ICH2hxY7SgmTxsQvfVqBmfHiY rZl6QXAYj/AZ4g1P/7S+dDlefOcrq0P4M4BjNN56L/1kPYIpDkdExETQsgW/3EK3t6Nz nwsQZzVvIIOKDOAcawQp8MatNHtEnQK2imDvPb145PrvTX9cRDbQnR8reP1rHcR6cyFl EoqH8hz/wMqMG/B0RuckCG1q7wuEXQf3+mED7DIqzga90b91FyA03Ldqbvk5LX/xx3Mf ITFQ== X-Received: by 10.50.122.8 with SMTP id lo8mr185407igb.31.1397778181358; Thu, 17 Apr 2014 16:43:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.147.69 with HTTP; Thu, 17 Apr 2014 16:42:41 -0700 (PDT) In-Reply-To: <1397714454341-5750340.post@n5.nabble.com> References: <1397714454341-5750340.post@n5.nabble.com> From: Claus Ibsen Date: Thu, 17 Apr 2014 16:42:41 -0700 Message-ID: Subject: Re: Camel Bindy - Issues with returntype To: "users@camel.apache.org" Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hi Bindy does not support mapping to java.util.Map. The idea is that you may from flatfile/csv to POJOs, where you annotate the POJOs with how to map. Maybe take a look at some of the other csv components/data formats, such as beanio, csv, flatpack You can see the list here http://camel.apache.org/data-format.html On Wed, Apr 16, 2014 at 11:00 PM, contactreji wrote: > Hi > > I am trying to parse some CSV data. Camel Bindy component seems to be doing > its job well. > When I am taking the data to a processor to access each Object separately > and do the processing, I see that Bindy returns a List and the List > contains a Hashmap!! > > Is there a way to configure Bindy to return a list of Java Objects instead > of Hashmap? > > I did a debug and the screenshot attached. In the debug view, we see that > exchange->in contains a HashMap. > > Can you suggest how can i retrieve the data? If its HashMap, what would be > the keys to retrieve the value? > > > > > > My Camel Code is > > * > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:amq="http://activemq.apache.org/schema/core" > xsi:schemaLocation=" > http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans.xsd > http://camel.apache.org/schema/spring > http://camel.apache.org/schema/spring/camel-spring.xsd > http://activemq.apache.org/schema/core > http://activemq.apache.org/schema/core/activemq-core.xsd"> > > > > class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat"> > > > > > > > > > contextPath="com.poc.camel.csv.java.bindy" /> > > > > > > > > > > > > > > > > > > > > > > > > * > > > And Java code is > > * > package com.poc.camel.csv.java.bindy; > > import java.util.ArrayList; > import java.util.HashMap; > import java.util.List; > import java.util.Map; > > import org.apache.camel.Exchange; > import org.apache.camel.Processor; > > public class HandleOrderBean implements Processor { > > > @SuppressWarnings("unchecked") > @Override > public void process(Exchange exchange) throws Exception { > // TODO Auto-generated method stub > > List list=new ArrayList(); > > > list = (List) exchange.getIn().getBody(); > > > System.out.println("Wanna convert things into XML now"); > > System.out.println("Wanna convert things into XML now"); > /*list.toString();*/ > > } > > > > > } > > > * > > > and My POJO class is > > package com.poc.camel.csv.java.bindy; > > import java.io.Serializable; > > import javax.xml.bind.annotation.XmlRootElement; > import org.apache.camel.dataformat.bindy.annotation.CsvRecord; > import org.apache.camel.dataformat.bindy.annotation.DataField; > > @XmlRootElement > @CsvRecord(separator = ",",crlf="WINDOWS",generateHeaderColumns=false) > public class Result implements Serializable{ > > @DataField(pos = 1) > private String firstName; > > @DataField(pos = 2) > private String lastName; > > @DataField(pos = 3) > private String rollNo; > > @DataField(pos = 4) > private String result; > > public String getFirstName() { > return firstName; > } > > public void setFirstName(String firstName) { > this.firstName = firstName; > } > > public String getLastName() { > return lastName; > } > > public void setLastName(String lastName) { > this.lastName = lastName; > } > > public String getRollNo() { > return rollNo; > } > > public void setRollNo(String rollNo) { > this.rollNo = rollNo; > } > > public String getResult() { > return result; > } > > public void setResult(String result) { > this.result = result; > } > > > > } > > > > -- > View this message in context: http://camel.465427.n5.nabble.com/Camel-Bindy-Issues-with-returntype-tp5750340.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. Email: cibsen@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/