[EMAIL PROTECTED] wrote:
Author: tv
Date: Fri Mar 21 12:21:55 2008
New Revision: 639770

URL: http://svn.apache.org/viewvc?rev=639770&view=rev
Log:
Made ValueParser and BaseValueParser locale-aware. Note that the default locale 
used is always the default value of the JVM which is different from the 
previous behaviour where the locale used was sometimes Locale.US (for float, 
double and BigDecimal) and sometimes the JVM-default (for dates).

TODO: Integration into RunData

Modified:
    
turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/BaseValueParser.java
    
turbine/core/branches/TURBINE_2_3_BRANCH/src/java/org/apache/turbine/util/parser/ValueParser.java
    
turbine/core/branches/TURBINE_2_3_BRANCH/src/test/org/apache/turbine/util/parser/BaseValueParserTest.java
    turbine/core/branches/TURBINE_2_3_BRANCH/xdocs/changes.xml
<snip/>
I have had a look at this and have the following comments:

  1. I think NumberFormat.parse() will convert "12.3foo" to 12.3 where
     as the old Double.parseDouble() would throw a
     NumberFormatException. I don't think we should be blindly dropping
     anything after the number so I think we need to detect this and
     throw an exception.  This also applies to the corresponding Float
     and BigDecimal methods.
2. Why doesn't getDoubleObject() just invoke getDouble()? getDoubleObjects() use getDoubles()? Being pedantic, getDouble()
     and getDoubles() have a common block of code that could be in a
     private method.  This would apply to many of the other methods
     also.  Whether or not these should be addressed is a matter of
     style - clearly they were like this before your changes.

Try adding the following to BaseValueParserTest.testGetDouble():
       parser.add("unparsable2", "1a");
       result = parser.getDouble("unparsable2");
       assertEquals(result, 0, 0);

The TurbineRunDataService change looks okay, but I will try it out shortly to confirm that I can easily override the locale on a per user basis.

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to