|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.struts.util.BeanUtils
Utility methods for populating JavaBeans properties via reflection.
Field Summary | |
private static int |
debug
Deprecated. The debugging detail level for this component. |
Constructor Summary | |
BeanUtils()
Deprecated. |
Method Summary | |
static java.lang.Object |
cloneBean(java.lang.Object bean)
Deprecated. Clone a bean based on the available property getters and setters, even if the bean class itself does not implement Cloneable. |
static java.util.Map |
describe(java.lang.Object bean)
Deprecated. Return the entire set of properties for which the specified bean provides a read method. |
static java.lang.String[] |
getArrayProperty(java.lang.Object bean,
java.lang.String name)
Deprecated. Return the value of the specified array property of the specified bean, as a String array. |
static int |
getDebug()
Deprecated. |
static java.lang.String |
getIndexedProperty(java.lang.Object bean,
java.lang.String name)
Deprecated. Return the value of the specified indexed property of the specified bean, as a String. |
static java.lang.String |
getIndexedProperty(java.lang.Object bean,
java.lang.String name,
int index)
Deprecated. Return the value of the specified indexed property of the specified bean, as a String. |
static java.lang.String |
getNestedProperty(java.lang.Object bean,
java.lang.String name)
Deprecated. Return the value of the (possibly nested) property of the specified name, for the specified bean, as a String. |
static java.lang.String |
getProperty(java.lang.Object bean,
java.lang.String name)
Deprecated. Return the value of the specified property of the specified bean, no matter which property reference format is used, as a String. |
static java.lang.String |
getSimpleProperty(java.lang.Object bean,
java.lang.String name)
Deprecated. Return the value of the specified simple property of the specified bean, converted to a String. |
static void |
populate(java.lang.Object bean,
java.util.Map properties)
Deprecated. Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs. |
static void |
setDebug(int newDebug)
Deprecated. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static int debug
Constructor Detail |
public BeanUtils()
Method Detail |
public static int getDebug()
public static void setDebug(int newDebug)
public static java.lang.Object cloneBean(java.lang.Object bean) throws java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
bean
- Bean to be clonedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.InstantiationException
- if a new instance of the bean's
class cannot be instantiatedjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.util.Map describe(java.lang.Object bean) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
BeanUtils.populate()
to reconsitute the same set of
properties, modulo differences for read-only and write-only
properties.bean
- Bean whose properties are to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String[] getArrayProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getIndexedProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
IllegalArgumentException
will be
thrown.bean
- Bean whose property is to be extractedname
- propertyname[index]
of the property value
to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getIndexedProperty(java.lang.Object bean, java.lang.String name, int index) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
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 extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getNestedProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Possibly nested name of the property to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.IllegalArgumentException
- if a nested reference to a
property returns nulljava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Possibly indexed and/or nested name of the property
to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static java.lang.String getSimpleProperty(java.lang.Object bean, java.lang.String name) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
bean
- Bean whose property is to be extractedname
- Name of the property to be extractedjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exceptionjava.lang.NoSuchMethodException
- if an accessor method for this
propety cannot be foundpublic static void populate(java.lang.Object bean, java.util.Map properties) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
String
, boolean
,
int
, long
, float
, and
double
. In addition, array setters for these types (or the
corresponding primitive types) can also be identified.
The particular setter method to be called for each property is determined using the usual JavaBeans introspection mechanisms. Thus, you may identify custom setter methods using a BeanInfo class that is associated with the class of the bean itself. If no such BeanInfo class is available, the standard method name conversion ("set" plus the capitalized name of the property in question) is used.
NOTE: It is contrary to the JavaBeans Specification to have more than one setter method (with different argument signatures) for the same property.
bean
- JavaBean whose properties are being populatedproperties
- Map keyed by property name, with the
corresponding (String or String[]) value(s) to be setjava.lang.IllegalAccessException
- if the caller does not have
access to the property accessor methodjava.lang.reflect.InvocationTargetException
- if the property accessor method
throws an exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |