History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-494
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Joerg Schaible
Reporter: Paolo Antinori
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

Select different parsing Integers method

Created: 17/May/08 12:07 PM   Updated: 17/May/08 12:07 PM
Component/s: Converters
Affects Version/s: 1.3
Fix Version/s: None


 Description  « Hide
Hi.

i've noted that the some basic converters:

ByteConverter
IntConverter
LongConverter
ShortConverter

use the decode method to parse a string into a number.

Even if this is the default parsing method supported by java,
sometimes it may not be the desired one.

for instance, if your working with numbers coming from a db or from
Cobol, the sequence "009" means just "9" while the decode method,
applying the java convention that parse a sequence starting with a "0"
as a octal number, reports an exception because 9 is an illegal
character in octal coding.

Java classes offer 2 different methods with 2 differents behaviours
for parsing sequence number:

for instance

java.lang.Integer

offers

decode(String nm) , that doesn't accept a sequence like "009" ,
java.lang.NumberFormatException

valueOf(String s) , that accept the sequence "009" and translate it in
the Integer representing the number 9

do you consider to offer the choice for this 2 different behaviours,
maybe in a flavour like the class BooleanConverter which offers
preconfigurated different instances for the differents desired
behaviours?

i guess that this change could apply to all integer based converters.

thanks

paolo



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.