Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.beanutils.BeanUtils
public class BeanUtils
extends java.lang.Object
BeanUtilsBean
.
These static utility methods use the default instance.
More sophisticated behaviour can be provided by using a BeanUtilsBean
instance.
BeanUtilsBean
Field Summary | |
private static int |
|
Method Summary | |
static Object |
|
static void |
|
static void |
|
static Map |
|
static String[] |
|
static int |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static boolean |
|
static void |
|
static void |
|
static void |
|
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. Note that this static variable will have unexpected side-effects if this class is deployed in a shared classloader within a container. However as it is actually completely ignored by this class due to its deprecated status, it doesn't do any actual harm.
public static Object cloneBean(Object bean) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException
Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean to be cloned
- Returns:
- the cloned bean
- See Also:
BeanUtilsBean.cloneBean(Object)
public static void copyProperties(Object dest, Object orig) throws IllegalAccessException, InvocationTargetException
Copy property values from the origin bean to the destination bean for all cases where the property names are the same. For more details seeBeanUtilsBean
.
- Parameters:
dest
- Destination bean whose properties are modifiedorig
- Origin bean whose properties are retrieved
public static void copyProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException
Copy the specified property value to the specified destination bean, performing any type conversion that is required. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be set
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 seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose properties are to be extracted
- Returns:
- Map of property descriptors
- See Also:
BeanUtilsBean.describe(Object)
public static String[] getArrayProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the value of the specified array property of the specified bean, as a String array. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
- Name of the property to be extracted
- Returns:
- The array property value
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.
Thedebug
static property is no longer used
- Returns:
- debug property
public static String getIndexedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the value of the specified indexed property of the specified bean, as a String. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
-propertyname[index]
of the property value to be extracted
- Returns:
- The indexed property's value, converted to a String
public static String getIndexedProperty(Object bean, String name, int index) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
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 seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
- Simple property name of the property value to be extractedindex
- Index of the property value to be extracted
- Returns:
- The indexed property's value, converted to a String
public static String getMappedProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the value of the specified indexed property of the specified bean, as a String. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
-propertyname(index)
of the property value to be extracted
- Returns:
- The mapped property's value, converted to a String
public static String getMappedProperty(Object bean, String name, String key) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the value of the specified mapped property of the specified bean, as a String. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
- Simple property name of the property value to be extractedkey
- Lookup key of the property value to be extracted
- Returns:
- The mapped property's value, converted to a String
public static String 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, as a String. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extracted
- Returns:
- The nested property's value, converted to a String
public static String 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, as a String. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property to be extracted
- Returns:
- The property's value, converted to a String
public static String getSimpleProperty(Object bean, String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
Return the value of the specified simple property of the specified bean, converted to a String. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean whose property is to be extractedname
- Name of the property to be extracted
- Returns:
- The property's value, converted to a String
public static boolean initCause(Throwable throwable, Throwable cause)
If we're running on JDK 1.4 or later, initialize the cause for the given throwable.
- Parameters:
throwable
- The throwable.cause
- The cause of the throwable.
- Returns:
- true if the cause was initialized, otherwise false.
public static void populate(Object bean, Map properties) throws IllegalAccessException, InvocationTargetException
Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs. For more details seeBeanUtilsBean
.
- Parameters:
bean
- JavaBean whose properties are being populatedproperties
- Map keyed by property name, with the corresponding (String or String[]) value(s) to be set
- See Also:
BeanUtilsBean.populate(Object,Map)
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.
Thedebug
static property is no longer used
- Parameters:
newDebug
- debug property
public static void setProperty(Object bean, String name, Object value) throws IllegalAccessException, InvocationTargetException
Set the specified property value, performing type conversions as required to conform to the type of the destination property. For more details seeBeanUtilsBean
.
- Parameters:
bean
- Bean on which setting is to be performedname
- Property name (can be nested/indexed/mapped/combo)value
- Value to be set