org.apache.commons.beanutils

Class 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 $
Authors:
Craig R. McClanahan
Ralph Schaer
Chris Audley
Rey Fran?ois
Gregor Ra?man
Jan Sorensen
Scott Sanders
See Also:
PropertyUtilsBean

Field Summary

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.
private static int
debug
Deprecated. The debug static property is no longer used

Method Summary

static void
clearDescriptors()
Clear any cached property descriptors information for all classes loaded by any class loaders.
static void
copyProperties(Object dest, 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 Map
describe(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 Object
getIndexedProperty(Object bean, String name)
Return the value of the specified indexed property of the specified bean, with no type conversions.
static Object
getIndexedProperty(Object bean, String name, int index)
Return the value of the specified indexed property of the specified bean, with no type conversions.
static Object
getMappedProperty(Object bean, String name)
Return the value of the specified mapped property of the specified bean, with no type conversions.
static Object
getMappedProperty(Object bean, String name, String key)
Return the value of the specified mapped property of the specified bean, with no type conversions.
static FastHashMap
getMappedPropertyDescriptors(Class beanClass)
Deprecated. This method should not be exposed
static FastHashMap
getMappedPropertyDescriptors(Object bean)
Deprecated. This method should not be exposed
static Object
getNestedProperty(Object bean, String name)
Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.
static Object
getProperty(Object bean, 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 PropertyDescriptor
getPropertyDescriptor(Object bean, String name)
Retrieve the property descriptor for the specified property of the specified bean, or return null if there is no such descriptor.
static PropertyDescriptor[]
getPropertyDescriptors(Class beanClass)
Retrieve the property descriptors for the specified class, introspecting and caching them the first time a particular bean class is encountered.
static PropertyDescriptor[]
getPropertyDescriptors(Object bean)
Retrieve the property descriptors for the specified bean, introspecting and caching them the first time a particular bean class is encountered.
static Class
getPropertyEditorClass(Object bean, String name)
Return the Java Class repesenting the property editor class that has been registered for this property (if any).
static Class
getPropertyType(Object bean, 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 Method
getReadMethod(PropertyDescriptor descriptor)
Return an accessible property getter method for this property, if there is one; otherwise return null.
static Object
getSimpleProperty(Object bean, String name)
Return the value of the specified simple property of the specified bean, with no type conversions.
static Method
getWriteMethod(PropertyDescriptor descriptor)
Return an accessible property setter method for this property, if there is one; otherwise return null.
static boolean
isReadable(Object bean, String name)
Return true if the specified property name identifies a readable property on the specified bean; otherwise, return false.
static boolean
isWriteable(Object bean, 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(Object bean, String name, Object value)
Sets the value of the specified indexed property of the specified bean, with no type conversions.
static void
setIndexedProperty(Object bean, String name, int index, Object value)
Sets the value of the specified indexed property of the specified bean, with no type conversions.
static void
setMappedProperty(Object bean, String name, Object value)
Sets the value of the specified mapped property of the specified bean, with no type conversions.
static void
setMappedProperty(Object bean, String name, String key, Object value)
Sets the value of the specified mapped property of the specified bean, with no type conversions.
static void
setNestedProperty(Object bean, String name, 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(Object bean, String name, 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(Object bean, String name, Object value)
Set the value of the specified simple property of the specified bean, with no type conversions.

Field Details

INDEXED_DELIM

public static final char INDEXED_DELIM
The delimiter that preceeds the zero-relative subscript for an indexed reference.
Field Value:
'['

INDEXED_DELIM2

public static final char INDEXED_DELIM2
The delimiter that follows the zero-relative subscript for an indexed reference.
Field Value:
']'

MAPPED_DELIM

public static final char MAPPED_DELIM
The delimiter that preceeds the key of a mapped property.
Field Value:
'('

MAPPED_DELIM2

public static final char MAPPED_DELIM2
The delimiter that follows the key of a mapped property.
Field Value:
')'

NESTED_DELIM

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

debug

private static int debug

Deprecated. The debug static property is no longer used

The debugging detail level for this component.

Method Details

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.


copyProperties

public static void copyProperties(Object dest,
                                  Object orig)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


describe

public static Map describe(Object bean)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the entire set of properties for which the specified bean provides a read method.

For more details see PropertyUtilsBean.


getDebug

public static int getDebug()

Deprecated. The debug static property is no longer used


getIndexedProperty

public static Object getIndexedProperty(Object bean,
                                        String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


getIndexedProperty

public static Object getIndexedProperty(Object bean,
                                        String name,
                                        int index)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


getMappedProperty

public static Object getMappedProperty(Object bean,
                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


getMappedProperty

public static Object getMappedProperty(Object bean,
                                       String name,
                                       String key)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


getMappedPropertyDescriptors

public static FastHashMap getMappedPropertyDescriptors(Class beanClass)

Deprecated. This method should not be exposed

Return the mapped property descriptors for this bean class.

For more details see PropertyUtilsBean.


getMappedPropertyDescriptors

public static FastHashMap getMappedPropertyDescriptors(Object bean)

Deprecated. This method should not be exposed

Return the mapped property descriptors for this bean.

For more details see PropertyUtilsBean.


getNestedProperty

public static Object getNestedProperty(Object bean,
                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


getProperty

public static Object getProperty(Object bean,
                                 String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


getPropertyDescriptor

public static PropertyDescriptor getPropertyDescriptor(Object bean,
                                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


getPropertyDescriptors

public static PropertyDescriptor[] getPropertyDescriptors(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.


getPropertyDescriptors

public static PropertyDescriptor[] getPropertyDescriptors(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.


getPropertyEditorClass

public static Class getPropertyEditorClass(Object bean,
                                           String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the Java Class repesenting the property editor class that has been registered for this property (if any).

For more details see PropertyUtilsBean.


getPropertyType

public static Class getPropertyType(Object bean,
                                    String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


getReadMethod

public static Method getReadMethod(PropertyDescriptor descriptor)
Return an accessible property getter method for this property, if there is one; otherwise return null.

For more details see PropertyUtilsBean.


getSimpleProperty

public static Object getSimpleProperty(Object bean,
                                       String name)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Return the value of the specified simple property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


getWriteMethod

public static Method getWriteMethod(PropertyDescriptor descriptor)
Return an accessible property setter method for this property, if there is one; otherwise return null.

For more details see PropertyUtilsBean.


isReadable

public static boolean isReadable(Object bean,
                                 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

isWriteable

public static boolean isWriteable(Object bean,
                                  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

setDebug

public static void setDebug(int newDebug)

Deprecated. The debug static property is no longer used


setIndexedProperty

public static void setIndexedProperty(Object bean,
                                      String name,
                                      Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Sets the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


setIndexedProperty

public static void setIndexedProperty(Object bean,
                                      String name,
                                      int index,
                                      Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Sets the value of the specified indexed property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


setMappedProperty

public static void setMappedProperty(Object bean,
                                     String name,
                                     Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Sets the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


setMappedProperty

public static void setMappedProperty(Object bean,
                                     String name,
                                     String key,
                                     Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Sets the value of the specified mapped property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


setNestedProperty

public static void setNestedProperty(Object bean,
                                     String name,
                                     Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


setProperty

public static void setProperty(Object bean,
                               String name,
                               Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   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.


setSimpleProperty

public static void setSimpleProperty(Object bean,
                                     String name,
                                     Object value)
            throws IllegalAccessException,
                   InvocationTargetException,
                   NoSuchMethodException
Set the value of the specified simple property of the specified bean, with no type conversions.

For more details see PropertyUtilsBean.


Copyright (c) 2001-2004 - Apache Software Foundation