commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <sma...@lfjr.net>
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));
config.getInteger("number");

throws a ClassCastException, but:

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

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

Mime
View raw message