commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Blaschke <>
Subject Re[4]: new project proposal: Type Conversion Library
Date Tue, 20 Jan 2004 17:03:32 GMT
Tuesday, January 20, 2004, 2:49:17 PM, you wrote:
SY> I'm still missing the "why" i.e. why do you want this package?  What are
SY> the use-cases?  Technical questions aside, I'd like to know the
SY> motivation for this project ;)

I have a user configuration (kinda like java.util.Properties) that
contains Strings, and a Seconds class whose sole contructor takes a
long.  In my opinion, the Seconds class should not need to know about
(most?) useful conversions, because often you can't. Eg, the only way
I know of to convert a Byte to an Integer is
Byte b = new Byte(10);
Integer i = new Integer(b.intValue());

(Should the Integer class have a constructor that takes a Number?)

Another thought that pops up is the conversion of String("3,5,2") to
an int[], or a List that contains Integers.

Maybe, something like
int[] foo = (int[]) TypeConverter.convert("3,5,2".split(","), int[].class);
List /* of Integer */ bar = (List) TypeConverter.convert("3,5,2".split(","),
/*container type*/List.class, /*element type*/Integer.class);

Again, such values exist in our (mostly internal) configuration files.

Besides, I'd like to see the constructor-valueOf-asList-toArray stuff cleaned
up a bit by a common interface.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message