You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/11/01 17:23:02 UTC

DO NOT REPLY [Bug 14170] New: - ConvertUtils.convert(Object) doesn't use registered convertor

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

           Summary: ConvertUtils.convert(Object) doesn't use registered
                    convertor
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Bean Utilities
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: brian.knorr@nextjet.com


The following is a detailed description of what we have found... any help is 
greatly appreciated:

Looking at the commons-beanutils source you will find the following method on 
BeanUtils.java:

    public static String getNestedProperty(Object bean, String name)
            throws IllegalAccessException, InvocationTargetException,
            NoSuchMethodException {

        Object value = PropertyUtils.getNestedProperty(bean, name);
        return (ConvertUtils.convert(value));
    }

***Please notice that it calls ConvertUtils.convert(value) - here is the source 
for that method:

    public static String convert(Object value) {
        if (value == null) {
            return ((String) null);
        } else if (value.getClass().isArray()) {
            if (Array.getLength(value) < 1) {
                return (null);
            }
            value = Array.get(value, 0);
            if (value == null)
                return ((String) null);
            else
                return (value.toString());
        } else {
            return (value.toString());
        }
    }

***As one can see the convert method never tries to use a registered 
convertor... is this a bug or its intended behavior?  When calling getProperty, 
getNestedProperty, or getSimpleProperty on BeanUtils.java we would like to have 
our registered convertor convert the Object to a String rather than the system 
calling toString.  Please advise...

Thanks,

Brian

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>