commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <>
Subject [configuration] Numbers conversions
Date Sun, 13 Jun 2004 12:58:27 GMT
Hello, I'm considering a change to improve the flexibility of 
[configuration] with regard to the numbers conversions. Currently any 
Number put in a configuration can't be retrieved as another Number type, 
for example:

config.setProperty("number", new Byte(123));

throws a ClassCastException, but:

config.setProperty("number", "123");

works fine.

The change consists in testing in the getXXX methods if the object 
retrieved is a Number and call the Number.xxxValue() method to convert 
it to the appropriate type. I'm attaching a patch and a test case to 
illustrate this.

What do you think ?

Emmanuel Bourg

View raw message