camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject git commit: CAMEL-6358 Fixed the issue of impliedDecimalSeparator doesn't work with big precision
Date Tue, 14 May 2013 07:40:30 GMT
Updated Branches:
  refs/heads/camel-2.11.x ee927c36d -> 6df857e22


CAMEL-6358 Fixed the issue of impliedDecimalSeparator doesn't work with big precision


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6df857e2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6df857e2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6df857e2

Branch: refs/heads/camel-2.11.x
Commit: 6df857e2248a5b7d4259581fd81335ce8a1716a9
Parents: ee927c3
Author: Willem Jiang <ningjiang@apache.org>
Authored: Tue May 14 11:13:12 2013 +0800
Committer: Willem Jiang <ningjiang@apache.org>
Committed: Tue May 14 15:38:46 2013 +0800

----------------------------------------------------------------------
 .../bindy/format/AbstractNumberFormat.java         |    6 +++---
 .../dataformat/bindy/format/BigDecimalFormat.java  |   11 ++++++-----
 2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6df857e2/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java
index daee298..6c42975 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/AbstractNumberFormat.java
@@ -29,7 +29,7 @@ public abstract class AbstractNumberFormat<T extends Number> implements
Format<T
     private boolean impliedDecimalPosition;
     private int precision;
     private DecimalFormat format;
-    private int multiplier;
+    private double multiplier;
 
     /**
      *
@@ -58,7 +58,7 @@ public abstract class AbstractNumberFormat<T extends Number> implements
Format<T
         if (this.impliedDecimalPosition) {
             this.format.setMinimumFractionDigits(0);
             this.format.setMaximumFractionDigits(0);
-            this.multiplier = (int)Math.pow(10D, precision);
+            this.multiplier = Math.pow(10D, precision);
         } else {
             this.format.setMinimumFractionDigits(this.precision);
             this.format.setMaximumFractionDigits(this.precision);
@@ -77,7 +77,7 @@ public abstract class AbstractNumberFormat<T extends Number> implements
Format<T
         return this.format;
     }
 
-    protected int getMultiplier() {
+    protected double getMultiplier() {
         return multiplier;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/6df857e2/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
index 3c903a6..defba11 100755
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/BigDecimalFormat.java
@@ -17,6 +17,7 @@
 package org.apache.camel.dataformat.bindy.format;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Locale;
 
 
@@ -35,12 +36,12 @@ public class BigDecimalFormat extends AbstractNumberFormat<BigDecimal>
{
     public BigDecimal parse(String string) throws Exception {
         BigDecimal result = new BigDecimal(string.trim());
         if (super.hasImpliedDecimalPosition()) {
-            result = result.divide(new BigDecimal(super.getMultiplier()));
+            result = result.divide(new BigDecimal(super.getMultiplier()), super.getPrecision(),
RoundingMode.HALF_EVEN);
+        } else {
+            if (super.getPrecision() != -1) {
+                result = result.setScale(super.getPrecision());
+            }
         }
-        if (super.getPrecision() != -1) {
-            result = result.setScale(super.getPrecision());
-        }
-
         return result;
     }
 }


Mime
View raw message