I am posting this here because I think commons would be the
right place to put such a library.  Please tell me if it's not.

The idea is to allow conversion for (almost?) any object into another.
I'd like to see code such as this working:

Object a = new Integer(10);
Object b = "120";

assertEquals(new Integer(10),
             TypeConverter.convert(a, Integer.class));
assertEquals(new Integer(120),
             TypeConverter.convert(b, Integer.class));

Of course, it should be extensible, and maybe allow for transitive
conversions, eg

class Seconds extends Time {}
TypeConverter.registerConverter(Integer.class, Seconds.class, /* some
converter object here */);

assertEquals(new Seconds(25), TypeConverter.convert("25",
Seconds.class); /* done via String -> Integer -> Seconds conversion */

Or add some constraint checking:
System.out.println(new Integer(128).byteValue()); /* prints -128; is
that what you wanted? */

Currently, I have only my ideas to donate (ie, no code yet), and have
not previously contributed to jakarta, so any guidance is appreciated.

Thanks,
Ron
--


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

Reply via email to