Could a describe method, the inverse of the populate method, be added to
the BeanUtils class, as attached

   michael


< [EMAIL PROTECTED] >

Index: src/share/org/apache/commons/beanutils/BeanUtils.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/beanutils/src/share/org/apache/commons/beanutils/BeanUtils.java,v
retrieving revision 1.1
diff -r1.1 BeanUtils.java
75a76
> import java.util.Collections;
77a79
> import java.util.HashMap;
485a488,505
>     /**
>      * Describe the specified JavaBean, returning a Map of
>      * property display name, (String or String[]) value(s).
>      *
>      * @param bean JavaBean whose properties are being described
>      *
>      * @return a Map keyed by property display name, with the
>      *  corresponding (String or String[]) value(s) from <code>bean</code>
>      *
>      * @exception IllegalAccessException if the caller does not have
>      *  access to the property accessor method
>      * @exception InvocationTargetException if the property accessor method
>      *  throws an exception
>      * @exception NoSuchMethodException if a method name returned by
>      *  getPropertyDescriptors doesn't exist upon invocation
>      */
>     public static Map describe(Object bean)
>       throws IllegalAccessException, InvocationTargetException, 
>NoSuchMethodException {
486a507,508
>       if (bean == null)
>           return Collections.EMPTY_MAP;
487a510,519
>       PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(bean);
>       Map description = new HashMap(descriptors.length);
>
>       for (int i = 0; i < descriptors.length; i++) {
>           description.put(descriptors[i].getDisplayName(),
>                           BeanUtils.getProperty(bean, descriptors[i].getName()));
>       }
>
>       return description;
>     }
488a521,526
>
>
>
>
>
>


Reply via email to