org.apache.commons.beanutils
Class PropertyUtils

java.lang.Object
  |
  +--org.apache.commons.beanutils.PropertyUtils

public class PropertyUtils
extends java.lang.Object

Utility methods for using Java Reflection APIs to facilitate generic property getter and setter operations on Java objects.

The implementations for these methods are provided by PropertyUtilsBean. For more details see PropertyUtilsBean.

Version:
$Revision: 1.42.2.1 $ $Date: 2004/07/27 21:31:00 $
Author:
Craig R. McClanahan, Ralph Schaer, Chris Audley, Rey François, Gregor Raıman, Jan Sorensen, Scott Sanders
See Also:
PropertyUtilsBean

Field Summary
private static int debug
          Deprecated. The debug static property is no longer used
static char INDEXED_DELIM
          The delimiter that preceeds the zero-relative subscript for an indexed reference.
static char INDEXED_DELIM2
          The delimiter that follows the zero-relative subscript for an indexed reference.
static char MAPPED_DELIM
          The delimiter that preceeds the key of a mapped property.
static char MAPPED_DELIM2
          The delimiter that follows the key of a mapped property.
static char NESTED_DELIM
          The delimiter that separates the components of a nested reference.
 
Constructor Summary
PropertyUtils()
           
 
Method Summary
static void clearDescriptors()
          Clear any cached property descriptors information for all classes loaded by any class loaders.
static void copyProperties(java.lang.Object dest, java.lang.Object orig)
          Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter and setter methods might have been customized via BeanInfo classes).
static java.util.Map describe(java.lang.Object bean)
          Return the entire set of properties for which the specified bean provides a read method.
static int getDebug()
          Deprecated. The debug static property is no longer used
static java.lang.Object getIndexedProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the specified indexed property of the specified bean, with no type conversions.
static java.lang.Object getIndexedProperty(java.lang.Object bean, java.lang.String name, int index)
          Return the value of the specified indexed property of the specified bean, with no type conversions.
static java.lang.Object getMappedProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the specified mapped property of the specified bean, with no type conversions.
static java.lang.Object getMappedProperty(java.lang.Object bean, java.lang.String name, java.lang.String key)
          Return the value of the specified mapped property of the specified bean, with no type conversions.
static FastHashMap getMappedPropertyDescriptors(java.lang.Class beanClass)
          Deprecated. This method should not be exposed
static FastHashMap getMappedPropertyDescriptors(java.lang.Object bean)
          Deprecated. This method should not be exposed
static java.lang.Object getNestedProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.
static java.lang.Object getProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Object bean, java.lang.String name)
          Retrieve the property descriptor for the specified property of the specified bean, or return null if there is no such descriptor.
static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Class beanClass)
          Retrieve the property descriptors for the specified class, introspecting and caching them the first time a particular bean class is encountered.
static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Object bean)
          Retrieve the property descriptors for the specified bean, introspecting and caching them the first time a particular bean class is encountered.
static java.lang.Class getPropertyEditorClass(java.lang.Object bean, java.lang.String name)
          Return the Java Class repesenting the property editor class that has been registered for this property (if any).
static java.lang.Class getPropertyType(java.lang.Object bean, java.lang.String name)
          Return the Java Class representing the property type of the specified property, or null if there is no such property for the specified bean.
static java.lang.reflect.Method getReadMethod(java.beans.PropertyDescriptor descriptor)
          Return an accessible property getter method for this property, if there is one; otherwise return null.
static java.lang.Object getSimpleProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the specified simple property of the specified bean, with no type conversions.
static java.lang.reflect.Method getWriteMethod(java.beans.PropertyDescriptor descriptor)
          Return an accessible property setter method for this property, if there is one; otherwise return null.
static boolean isReadable(java.lang.Object bean, java.lang.String name)
          Return true if the specified property name identifies a readable property on the specified bean; otherwise, return false.
static boolean isWriteable(java.lang.Object bean, java.lang.String name)
          Return true if the specified property name identifies a writeable property on the specified bean; otherwise, return false.
static void setDebug(int newDebug)
          Deprecated. The debug static property is no longer used
static void setIndexedProperty(java.lang.Object bean, java.lang.String name, int index, java.lang.Object value)
          Sets the value of the specified indexed property of the specified bean, with no type conversions.
static void setIndexedProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
          Sets the value of the specified indexed property of the specified bean, with no type conversions.
static void setMappedProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
          Sets the value of the specified mapped property of the specified bean, with no type conversions.
static void setMappedProperty(java.lang.Object bean, java.lang.String name, java.lang.String key, java.lang.Object value)
          Sets the value of the specified mapped property of the specified bean, with no type conversions.
static void setNestedProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
          Sets the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.
static void setProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
          Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
static void setSimpleProperty(java.lang.Object bean, java.lang.String name, java.lang.Object value)
          Set the value of the specified simple property of the specified bean, with no type conversions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEXED_DELIM

public static final char INDEXED_DELIM
The delimiter that preceeds the zero-relative subscript for an indexed reference.

See Also:
Constant Field Values

INDEXED_DELIM2

public static final char INDEXED_DELIM2
The delimiter that follows the zero-relative subscript for an indexed reference.

See Also:
Constant Field Values

MAPPED_DELIM

public static final char MAPPED_DELIM
The delimiter that preceeds the key of a mapped property.

See Also:
Constant Field Values

MAPPED_DELIM2

public static final char MAPPED_DELIM2
The delimiter that follows the key of a mapped property.

See Also:
Constant Field Values

NESTED_DELIM

public static final char NESTED_DELIM
The delimiter that separates the components of a nested reference.

See Also:
Constant Field Values

debug

private static int debug
Deprecated. The debug static property is no longer used

The debugging detail level for this component.

Constructor Detail

PropertyUtils

public PropertyUtils()
Method Detail

getDebug

public static int getDebug()
Deprecated. The debug static property is no longer used


setDebug

public static void setDebug(int newDebug)
Deprecated. The debug static property is no longer used


clearDescriptors

public static void clearDescriptors()
Clear any cached property descriptors information for all classes loaded by any class loaders. This is useful in cases where class loaders are thrown away to implement class reloading.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.clearDescriptors()

copyProperties

public static void copyProperties(java.lang.Object dest,
                                  java.lang.Object orig)
                           throws java.lang.IllegalAccessException,
                                  java.lang.reflect.InvocationTargetException,
                                  java.lang.NoSuchMethodException

Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter and setter methods might have been customized via BeanInfo classes).

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.copyProperties(java.lang.Object, java.lang.Object)

describe

public static java.util.Map describe(java.lang.Object bean)
                              throws java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.NoSuchMethodException

Return the entire set of properties for which the specified bean provides a read method.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.describe(java.lang.Object)

getIndexedProperty

public static java.lang.Object getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.NoSuchMethodException

Return the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getIndexedProperty(Object,String)

getIndexedProperty

public static java.lang.Object getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name,
                                                  int index)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.NoSuchMethodException

Return the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getIndexedProperty(Object,String, int)

getMappedProperty

public static java.lang.Object getMappedProperty(java.lang.Object bean,
                                                 java.lang.String name)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

Return the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getMappedProperty(Object,String)

getMappedProperty

public static java.lang.Object getMappedProperty(java.lang.Object bean,
                                                 java.lang.String name,
                                                 java.lang.String key)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

Return the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getMappedProperty(Object,String, String)

getMappedPropertyDescriptors

public static FastHashMap getMappedPropertyDescriptors(java.lang.Class beanClass)
Deprecated. This method should not be exposed

Return the mapped property descriptors for this bean class.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.getMappedPropertyDescriptors(Class)

getMappedPropertyDescriptors

public static FastHashMap getMappedPropertyDescriptors(java.lang.Object bean)
Deprecated. This method should not be exposed

Return the mapped property descriptors for this bean.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.getMappedPropertyDescriptors(Object)

getNestedProperty

public static java.lang.Object getNestedProperty(java.lang.Object bean,
                                                 java.lang.String name)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getNestedProperty(java.lang.Object, java.lang.String)

getProperty

public static java.lang.Object getProperty(java.lang.Object bean,
                                           java.lang.String name)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.reflect.InvocationTargetException,
                                           java.lang.NoSuchMethodException

Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getProperty(java.lang.Object, java.lang.String)

getPropertyDescriptor

public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Object bean,
                                                                  java.lang.String name)
                                                           throws java.lang.IllegalAccessException,
                                                                  java.lang.reflect.InvocationTargetException,
                                                                  java.lang.NoSuchMethodException

Retrieve the property descriptor for the specified property of the specified bean, or return null if there is no such descriptor.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getPropertyDescriptor(java.lang.Object, java.lang.String)

getPropertyDescriptors

public static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Class beanClass)

Retrieve the property descriptors for the specified class, introspecting and caching them the first time a particular bean class is encountered.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.getPropertyDescriptors(Class)

getPropertyDescriptors

public static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Object bean)

Retrieve the property descriptors for the specified bean, introspecting and caching them the first time a particular bean class is encountered.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.getPropertyDescriptors(Object)

getPropertyEditorClass

public static java.lang.Class getPropertyEditorClass(java.lang.Object bean,
                                                     java.lang.String name)
                                              throws java.lang.IllegalAccessException,
                                                     java.lang.reflect.InvocationTargetException,
                                                     java.lang.NoSuchMethodException

Return the Java Class repesenting the property editor class that has been registered for this property (if any).

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getPropertyEditorClass(Object,String)

getPropertyType

public static java.lang.Class getPropertyType(java.lang.Object bean,
                                              java.lang.String name)
                                       throws java.lang.IllegalAccessException,
                                              java.lang.reflect.InvocationTargetException,
                                              java.lang.NoSuchMethodException

Return the Java Class representing the property type of the specified property, or null if there is no such property for the specified bean.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getPropertyType(java.lang.Object, java.lang.String)

getReadMethod

public static java.lang.reflect.Method getReadMethod(java.beans.PropertyDescriptor descriptor)

Return an accessible property getter method for this property, if there is one; otherwise return null.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.getReadMethod(java.beans.PropertyDescriptor)

getSimpleProperty

public static java.lang.Object getSimpleProperty(java.lang.Object bean,
                                                 java.lang.String name)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.reflect.InvocationTargetException,
                                                 java.lang.NoSuchMethodException

Return the value of the specified simple property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.getSimpleProperty(java.lang.Object, java.lang.String)

getWriteMethod

public static java.lang.reflect.Method getWriteMethod(java.beans.PropertyDescriptor descriptor)

Return an accessible property setter method for this property, if there is one; otherwise return null.

For more details see PropertyUtilsBean.

See Also:
PropertyUtilsBean.getWriteMethod(java.beans.PropertyDescriptor)

isReadable

public static boolean isReadable(java.lang.Object bean,
                                 java.lang.String name)

Return true if the specified property name identifies a readable property on the specified bean; otherwise, return false.

For more details see PropertyUtilsBean.

Since:
BeanUtils 1.6
See Also:
PropertyUtilsBean.isReadable(java.lang.Object, java.lang.String)

isWriteable

public static boolean isWriteable(java.lang.Object bean,
                                  java.lang.String name)

Return true if the specified property name identifies a writeable property on the specified bean; otherwise, return false.

For more details see PropertyUtilsBean.

Since:
BeanUtils 1.6
See Also:
PropertyUtilsBean.isWriteable(java.lang.Object, java.lang.String)

setIndexedProperty

public static void setIndexedProperty(java.lang.Object bean,
                                      java.lang.String name,
                                      java.lang.Object value)
                               throws java.lang.IllegalAccessException,
                                      java.lang.reflect.InvocationTargetException,
                                      java.lang.NoSuchMethodException

Sets the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setIndexedProperty(Object, String, Object)

setIndexedProperty

public static void setIndexedProperty(java.lang.Object bean,
                                      java.lang.String name,
                                      int index,
                                      java.lang.Object value)
                               throws java.lang.IllegalAccessException,
                                      java.lang.reflect.InvocationTargetException,
                                      java.lang.NoSuchMethodException

Sets the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setIndexedProperty(Object, String, Object)

setMappedProperty

public static void setMappedProperty(java.lang.Object bean,
                                     java.lang.String name,
                                     java.lang.Object value)
                              throws java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.NoSuchMethodException

Sets the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setMappedProperty(Object, String, Object)

setMappedProperty

public static void setMappedProperty(java.lang.Object bean,
                                     java.lang.String name,
                                     java.lang.String key,
                                     java.lang.Object value)
                              throws java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.NoSuchMethodException

Sets the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setMappedProperty(Object, String, String, Object)

setNestedProperty

public static void setNestedProperty(java.lang.Object bean,
                                     java.lang.String name,
                                     java.lang.Object value)
                              throws java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.NoSuchMethodException

Sets the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setNestedProperty(java.lang.Object, java.lang.String, java.lang.Object)

setProperty

public static void setProperty(java.lang.Object bean,
                               java.lang.String name,
                               java.lang.Object value)
                        throws java.lang.IllegalAccessException,
                               java.lang.reflect.InvocationTargetException,
                               java.lang.NoSuchMethodException

Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setProperty(java.lang.Object, java.lang.String, java.lang.Object)

setSimpleProperty

public static void setSimpleProperty(java.lang.Object bean,
                                     java.lang.String name,
                                     java.lang.Object value)
                              throws java.lang.IllegalAccessException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.NoSuchMethodException

Set the value of the specified simple property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.

java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
See Also:
PropertyUtilsBean.setSimpleProperty(java.lang.Object, java.lang.String, java.lang.Object)


Copyright (c) 2001-2004 - Apache Software Foundation