commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Blaschke <>
Subject Re[2]: new project proposal: Type Conversion Library
Date Mon, 19 Jan 2004 23:32:07 GMT
Monday, January 19, 2004, 11:34:36 PM, you wrote:
SK> On Tue, 2004-01-20 at 11:07, Ron Blaschke wrote:
>> 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:

SK> Have you looked at ConvertUtils in the BeanUtils library yet?


SK> It does pretty much what you describe here. You may wish to look at
SK> that, then send a mail describing how your ideas differ from what is
SK> already there..

In ConvertUtils, the conversion relies a lot on JDK implementations,
which is quite "relaxed."  Eg, Integer(128) -| Byte(-128),
Double(1.3d) -| Integer(1), etc.  I'd like to see a more configurable
approach, for example:
strict: "1.23" -| Integer   ... not possible, raise Exception
relaxed: "1.23" -| Integer(1)   ... seems ok

strict: Integer(128) -| Byte    ... no way! raise Exception
relaxed: Integer(128) -| Byte(127) ... close enough

The converter should enable transitive conversions, that is if one
converter knows about A to B conversion, and another from B to C, both
together should know about A to C.  In the Seconds example, it would
suffice for the user supplied Seconds converter to know about
Integers to allow conversion from String via Integer to Second.
In ConvertUtil, the converter must know about all possible conversions
(well, most of it is handed off to Java, which is ok, but I'd rather
not go down that lane.)

That's all that is on top of my head.  For more, I'd have to dig a day
or so. :-)


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

View raw message