DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30272>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30272

Better integration with ConvertUtils

           Summary: Better integration with ConvertUtils
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: JXPath
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


actually, ConvertUtils from BeanUtils is used like this in the 
BasicTypeConverter:

if (ConvertUtils.lookup(toType) != null) {
  return ConvertUtils.convert(object.toString(), toType);
}

the toString() could cause some problem: imagine that my property is a Date and 
I would like it to be converted to an Integer like this:

context.getValue("record/lastModificationDate", Integer.class);

The toString() will get me something like 'November Wed 17h, 2002' then will 
try to convert this to a number which is kinda problematic because it is now a 
string and you've lost the fact that it was a date before (which is required to 
know how to convert it).

I propose to skip the toString() by directly using the looked up Converter 
which can take an object as argument instead of a string:

Converter converter = ConvertUtils.lookup(toType);
if (converter != null) {
    return converter.convert(toType, object);
}

By the way, did you take a look at the Convert component in the commons sandbox?

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

Reply via email to