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 8B989110FC for ; Wed, 20 Aug 2014 18:39:50 +0000 (UTC) Received: (qmail 52595 invoked by uid 500); 20 Aug 2014 18:39:50 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 52542 invoked by uid 500); 20 Aug 2014 18:39:50 -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 52530 invoked by uid 99); 20 Aug 2014 18:39:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2014 18:39:49 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of a_blithe@web.de designates 212.227.15.3 as permitted sender) Received: from [212.227.15.3] (HELO mout.web.de) (212.227.15.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Aug 2014 18:39:45 +0000 Received: from [93.196.177.240] by msvc084.server.lan (via HTTP); Wed, 20 Aug 2014 20:39:24 +0200 MIME-Version: 1.0 Message-ID: From: a_blithe@web.de To: users@camel.apache.org Subject: Re: Re: Camel Bindy: parse a BigDecimal number with a given pattern Content-Type: text/plain; charset=UTF-8 Importance: normal Date: Wed, 20 Aug 2014 20:39:24 +0200 Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-Provags-ID: V03:K0:zBPXqzO4/8p9ghBIEoj+hX7i3fA+0FlCkP3ApWDGX2+ jhQUyAKcAAGD0AJLwl5OBlIfzQajAZWkC650Oymhu7qG8IyjhG wf3FxFZIREU0DQxneNokpckYMQWnvQvAwTrDBIQh4r9M97TTMy uL8Tg3fUutrr+w7l1bw0KHGy+4YK+MJ9iJAhYQYq0m2DJv24rN HQPk91/dx0ruIEt5dWGV2B1Sx/262ID4rn4AdhEyjUZ5iVqGWs YSR+PgKpKKIm05G8wgslcBZ2g0Gfxev3F4w== X-UI-Out-Filterresults: notjunk:1; X-Virus-Checked: Checked by ClamAV on apache.org The numbers I'd like to parse could have one the following structures: 123,456,789.01 123.45 -1234 1,234 (there are several rows in one file so it is possible that different struc= tures appear in a file) Setting the precision already works fine and the decimal separator is trea= ted correctly. The current problem is that I can't tell bindy to ignore the comma sings i= n every number, because they are for grouping purposes and not needed in the BigDecimal fi= eld. If I keep the comma sign in these numbers the parsing process will raise a= NumberFormatException mentioning a malformed number. If I remove that comma signs in a test file= , everything works fine and the number is mapped to the datafield correctly, but sadly that can't be a solution, = because this csv files are provided by different system that cannot be changed. If I use the following annotation @DataField(pos =3D 2, precision =3D 2, pattern =3D "#,###.##") and use Double instead of BigDecimal I can keep the comma sings. But I can= 't use Double for several reasons. The source code of the FormatFactory class (version 2.13.1) that I linked = in my question also shows that the pattern is used for Double types (and se= veral other types) but not for BigDecimal types. -----Urspr=C3=BCngliche Nachricht----- Gesendet: Wednesday, 20 August 2014 um 19:33:05 Uhr Von: "Charles Moulliard" An: users@camel.apache.org Betreff: Re: Camel Bindy: parse a BigDecimal number with a given pattern The @DataField of Camel bindy proposes the parameter precision like also a pattern but not a grouping separator Example @DataField(pos =3D 2, precision =3D 2, pattern =3D "00.00") private BigDecimal bigDecimal; Do you have an example to propose about such use case ? On Wed, Aug 20, 2014 at 3:43 PM, wrote: > Hello, > > I currently have a problem concerning Camel Bindy. I have a csv file tha= t > should be parsed with Camel Bindy using a given model class. This csv fi= le > contains a number that should be parsed as a BigDecimal. The problem is > that > this number contains a comma as a grouping separator and a point as the > decimal separator. > If I start the camel route the unmarshal process will throw a > NumberFormatException mentioning the invalid format of that number. So I > tried to add a pattern to the DataField annotation, but the error stays. > > After digging throw the documentation (http://camel.apache.org/bindy.htm= l) > and the source code of FormatFactory > ( > http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.camel/camel-= bindy/2.13.1/org/apache/camel/dataformat/bindy/FormatFactory.java/?v=3Dsour= ce > ) > I'm a little bit confused, because the documentation mentions the abilit= y > to > specify a grouping separator, but the source code shows that the pattern= is > ignored for BigDecimal data types. > > Does anyone know how to specify that grouping separator? Or is this not > implemented yet? > > Many thanks in advance. > > Best regards. > Tom > > P.S. I also posted that question on stackoverflow > ( > http://stackoverflow.com/questions/25381052/camel-bindy-add-pattern-for-= bigdecimal-type > ), > but with no luck yet. > > P.P.S. I posted that question using nabble.com ( > http://camel.465427.n5.nabble.com/Camel-Users-f465428.html) some moments > ago, but it seems that there is a problem with my mail provider that > doesn't allow services like this. So I'm sending this question directly > now. Sorry for any inconveniences. > --=20 Charles Moulliard Apache Committer / Architect @RedHat Twitter : @cmoulliard | Blog : http://cmoulliard.github.io