commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14170] - ConvertUtils.convert(Object) doesn't use registered convertor
Date Tue, 08 Apr 2003 02:32:21 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14170>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14170

ConvertUtils.convert(Object) doesn't use registered convertor





------- Additional Comments From ericpabst@discoverfinancial.com  2003-04-08 02:32 -------
>A longer term solution would be to move towards bidirectional converters 
>of some sort. 

I am preparing a patch to ConvertUtils that supports registering a Converter 
with specifying both the source class and the target class.  This allows for 
registering separate Converter's for Number->String, Date->String, etc. by 
overloading register, lookup, and deregister to allow for two Class parameters 
(targetClass and sourceClass).  Should I do it as a sub-class of 
ConvertUtilsBean without modifying ConvertUtils or should I go ahead and 
integrate it into these two classes?  

For backwards compatibility, I was thinking of implementing all the methods 
with only one Class parameter (e.g. register(Converter, Class)) by having a 
default source class of java.lang.Object.  This can be interpreted as a 
Converter that can convert ANY type of Object to the specified target class.  
Then, the ConvertUtilsBean.lookup(Class, Class) method will look first for the 
specific Converter between the two classes, and if it finds none, it will look 
for one using java.lang.Object as the source class.  We could later generalize 
it to look for a Converter that is compatible (e.g. if a Converter is 
registered from Date to String, then when looking for a Converter from 
java.sql.Timestamp to String, it could use that Converter).  

Any thoughts?

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message