commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Knorr" <>
Subject ConvertUtils.convert(Object) doesn't use registered convertor
Date Thu, 31 Oct 2002 22:12:41 GMT
Tried sending this to commons-user mailing list several times now, but
haven't gotten a response... thought I would try the dev list instead...

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

    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);
                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
we would like to have our registered convertor convert the Object to a
String rather than the system calling toString.  Please advise...



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

View raw message