You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2005/09/11 16:18:56 UTC

svn commit: r280143 - /jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java

Author: henning
Date: Sun Sep 11 07:18:54 2005
New Revision: 280143

URL: http://svn.apache.org/viewcvs?rev=280143&view=rev
Log:
Make sure to trim() String values before converting into number types.

The DataStreamParser should (must, according to e.g. the CSV spec)
keep trailing and leading blanks, so the BaseValue parser must strip
these off or there will be a NumberFormatException.


Modified:
    jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java

Modified: jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java?rev=280143&r1=280142&r2=280143&view=diff
==============================================================================
--- jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java (original)
+++ jakarta/turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java Sun Sep 11 07:18:54 2005
@@ -497,7 +497,7 @@
 
         try
         {
-            result = Double.parseDouble(value);
+            result = Double.parseDouble(StringUtils.trim(value));
         }
         catch (NumberFormatException e)
         {
@@ -584,7 +584,7 @@
 
         try
         {
-            result = new Double(value);
+            result = new Double(StringUtils.trim(value));
         }
         catch(NumberFormatException e)
         {
@@ -645,7 +645,7 @@
 
         try
         {
-            result = Float.parseFloat(value);
+            result = Float.parseFloat(StringUtils.trim(value));
         }
         catch (NumberFormatException e)
         {
@@ -732,7 +732,7 @@
 
         try
         {
-            result = new Float(value);
+            result = new Float(StringUtils.trim(value));
         }
         catch(NumberFormatException e)
         {
@@ -794,7 +794,7 @@
 
         try
         {
-            result = new BigDecimal(value);
+            result = new BigDecimal(StringUtils.trim(value));
         }
         catch (NumberFormatException e)
         {
@@ -868,7 +868,7 @@
 
         try
         {
-            result = Integer.valueOf(value).intValue();
+            result = Integer.parseInt(StringUtils.trim(value));
         }
         catch (NumberFormatException e)
         {
@@ -997,7 +997,7 @@
 
         try
         {
-            result = new Integer(value);
+            result = new Integer(StringUtils.trim(value));
         }
         catch(NumberFormatException e)
         {
@@ -1072,7 +1072,7 @@
 
         try
         {
-            result = Long.valueOf(value).longValue();
+            result = Long.parseLong(StringUtils.trim(value));
         }
         catch (NumberFormatException e)
         {
@@ -1178,7 +1178,7 @@
 
         try
         {
-            result = new Long(value);
+            result = new Long(StringUtils.trim(value));
         }
         catch(NumberFormatException e)
         {
@@ -1221,7 +1221,7 @@
 
         try
         {
-            result = Byte.valueOf(value).byteValue();
+            result = Byte.parseByte(StringUtils.trim(value));
         }
         catch (NumberFormatException e)
         {
@@ -1296,7 +1296,7 @@
 
         try
         {
-            result = new Byte(value);
+            result = new Byte(StringUtils.trim(value));
         }
         catch(NumberFormatException e)
         {
@@ -1689,7 +1689,7 @@
     }
 
     /**
-     * This method is only used in toString() and can be used by 
+     * This method is only used in toString() and can be used by
      * derived classes to add their local parameters to the toString()
 
      * @param name A string with the name



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org