org.apache.commons.beanutils

Class BeanUtils

public class BeanUtils extends Object

Utility methods for populating JavaBeans properties via reflection.

The implementations are provided by BeanUtilsBean. These static utility methods use the default instance. More sophisticated behaviour can be provided by using a BeanUtilsBean instance.

Version: $Revision: 1.40 $ $Date: 2004/02/28 13:18:33 $

Author: Craig R. McClanahan Ralph Schaer Chris Audley Rey Frangois Gregor Ra}man

See Also: BeanUtilsBean

Field Summary
static intdebug
The debugging detail level for this component.
static FastHashMapdummy
Dummy collection from the Commons Collections API, to force a ClassNotFoundException if commons-collections.jar is not present in the runtime classpath, and this class is the first one referenced.
Method Summary
static ObjectcloneBean(Object bean)

Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.

For more details see BeanUtilsBean.

static voidcopyProperties(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.

For more details see BeanUtilsBean.

static voidcopyProperty(Object bean, String name, Object value)

Copy the specified property value to the specified destination bean, performing any type conversion that is required.

For more details see BeanUtilsBean.

static Mapdescribe(Object bean)

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

For more details see BeanUtilsBean.

static String[]getArrayProperty(Object bean, String name)

Return the value of the specified array property of the specified bean, as a String array.

For more details see BeanUtilsBean.

static intgetDebug()
static StringgetIndexedProperty(Object bean, String name)

Return the value of the specified indexed property of the specified bean, as a String.

For more details see BeanUtilsBean.

static StringgetIndexedProperty(Object bean, String name, int index)
Return the value of the specified indexed property of the specified bean, as a String.
static StringgetMappedProperty(Object bean, String name)

Return the value of the specified indexed property of the specified bean, as a String.

For more details see BeanUtilsBean.

static StringgetMappedProperty(Object bean, String name, String key)

Return the value of the specified mapped property of the specified bean, as a String.

For more details see BeanUtilsBean.

static StringgetNestedProperty(Object bean, String name)

Return the value of the (possibly nested) property of the specified name, for the specified bean, as a String.

For more details see BeanUtilsBean.

static StringgetProperty(Object bean, String name)

Return the value of the specified property of the specified bean, no matter which property reference format is used, as a String.

For more details see BeanUtilsBean.

static StringgetSimpleProperty(Object bean, String name)

Return the value of the specified simple property of the specified bean, converted to a String.

For more details see BeanUtilsBean.

static voidpopulate(Object bean, Map properties)

Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs.

For more details see BeanUtilsBean.

static voidsetDebug(int newDebug)
static voidsetProperty(Object bean, String name, Object value)

Set the specified property value, performing type conversions as required to conform to the type of the destination property.

For more details see BeanUtilsBean.

Field Detail

debug

private static int debug

Deprecated: BeanUtils now uses commons-logging for all log messages. Use your favorite logging tool to configure logging for this class.

The debugging detail level for this component.

dummy

private static FastHashMap dummy
Dummy collection from the Commons Collections API, to force a ClassNotFoundException if commons-collections.jar is not present in the runtime classpath, and this class is the first one referenced. Otherwise, the ClassNotFoundException thrown by ConvertUtils or PropertyUtils can get masked.

Method Detail

cloneBean

public static Object cloneBean(Object bean)

Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

copyProperties

public 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.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

copyProperty

public static void copyProperty(Object bean, String name, Object value)

Copy the specified property value to the specified destination bean, performing any type conversion that is required.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

describe

public static Map describe(Object bean)

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

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getArrayProperty

public static String[] getArrayProperty(Object bean, String name)

Return the value of the specified array property of the specified bean, as a String array.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getDebug

public static int getDebug()

Deprecated: BeanUtils now uses commons-logging for all log messages. Use your favorite logging tool to configure logging for this class.

getIndexedProperty

public static String getIndexedProperty(Object bean, String name)

Return the value of the specified indexed property of the specified bean, as a String.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getIndexedProperty

public static String getIndexedProperty(Object bean, String name, int index)
Return the value of the specified indexed property of the specified bean, as a String. The index is specified as a method parameter and must *not* be included in the property name expression

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getMappedProperty

public static String getMappedProperty(Object bean, String name)

Return the value of the specified indexed property of the specified bean, as a String.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getMappedProperty

public static String getMappedProperty(Object bean, String name, String key)

Return the value of the specified mapped property of the specified bean, as a String.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getNestedProperty

public static String getNestedProperty(Object bean, String name)

Return the value of the (possibly nested) property of the specified name, for the specified bean, as a String.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getProperty

public static String getProperty(Object bean, String name)

Return the value of the specified property of the specified bean, no matter which property reference format is used, as a String.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

getSimpleProperty

public static String getSimpleProperty(Object bean, String name)

Return the value of the specified simple property of the specified bean, converted to a String.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

populate

public static void populate(Object bean, Map properties)

Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

setDebug

public static void setDebug(int newDebug)

Deprecated: BeanUtils now uses commons-logging for all log messages. Use your favorite logging tool to configure logging for this class.

setProperty

public static void setProperty(Object bean, String name, Object value)

Set the specified property value, performing type conversions as required to conform to the type of the destination property.

For more details see BeanUtilsBean.

See Also: BeanUtilsBean

Copyright (c) 2001-2004 - Apache Software Foundation