public class BonesOfBeans
extends java.lang.Object
HGException
which will wrap the underlying bean introspection
and reflection (for set and get) exceptions.Constructor and Description |
---|
BonesOfBeans() |
Modifier and Type | Method and Description |
---|---|
static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> |
getAllPropertyDescriptors(java.lang.Class<?> beanClass) |
static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> |
getAllPropertyDescriptors(java.lang.Object bean) |
static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> |
getAllPropertyDescriptorsEx(java.lang.Class<?> beanClass) |
static java.util.Map<java.lang.String,java.lang.Object> |
getPropertiesAsMap(java.lang.Object bean)
Return a Java Map of all read-write properties of the specified Java bean.
|
static java.lang.Object |
getProperty(java.lang.Object bean,
java.beans.PropertyDescriptor prop)
Same as
getProperty(Object, String) , but use a supplied
PropertyDescriptor instead of the property name. |
static java.lang.Object |
getProperty(java.lang.Object bean,
java.beans.PropertyDescriptor prop,
int index)
Same as
getProperty(Object, String, int) , but use a supplied
PropertyDescriptor instead of the property name. |
static java.lang.Object |
getProperty(java.lang.Object bean,
java.lang.String propname)
Get the value of a particular bean property.
|
static java.lang.Object |
getProperty(java.lang.Object bean,
java.lang.String propname,
int index)
Get the value of a particular (indexed) bean property.
|
static java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.Class<?> clazz,
java.lang.String propname) |
static java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.Object bean,
java.lang.String propname) |
static java.lang.Object |
makeBean(java.lang.String classname)
Construct a new instance of a bean.
|
static java.lang.Class<?> |
primitiveEquivalentOf(java.lang.Class<?> aClass) |
static void |
setPropertiesFromMap(java.lang.Object bean,
java.util.Map<java.lang.String,java.lang.Object> properties) |
static void |
setProperty(java.lang.Object bean,
java.beans.PropertyDescriptor prop,
int index,
java.lang.Object newvalue)
Same as
setProperty(Object, String, int, Object) , but use a
supplied PropertyDescriptor instead of the property name. |
static void |
setProperty(java.lang.Object bean,
java.beans.PropertyDescriptor prop,
java.lang.Object newvalue)
Same as
setProperty(Object, String, Object) , but use a
supplied PropertyDescriptor instead of the property name. |
static void |
setProperty(java.lang.Object bean,
java.lang.String propname,
int index,
java.lang.Object newvalue)
Assign a new value to a specified bean property.
|
static void |
setProperty(java.lang.Object bean,
java.lang.String propname,
java.lang.Object newvalue)
Assign a new value to a specified bean property.
|
static java.lang.Class<?> |
wrapperEquivalentOf(java.lang.Class<?> aClass) |
public static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> getAllPropertyDescriptors(java.lang.Class<?> beanClass)
beanClass
- The bean class whose property descriptors are desired. Cannot
be null
.Map
of all property descriptors in the bean. The
map elements are keyed by property name.public static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> getAllPropertyDescriptorsEx(java.lang.Class<?> beanClass)
public static java.util.Map<java.lang.String,java.beans.PropertyDescriptor> getAllPropertyDescriptors(java.lang.Object bean)
bean
- The bean whose property descriptors are desired. Cannot be
null
Map
of all property descriptors in the bean. The
map elements are keyed by property name.public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Object bean, java.lang.String propname)
bean
- Any object conforming to the Java Beans Specificationpropname
- The name a bean property.PropertyDescriptor
for that property as returned
from the BeanInfo
associated with that bean. If
there is no property with that name in the bean,
null
is returned.public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class<?> clazz, java.lang.String propname)
public static java.lang.Object getProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop, int index)
getProperty(Object, String, int)
, but use a supplied
PropertyDescriptor
instead of the property name.public static java.util.Map<java.lang.String,java.lang.Object> getPropertiesAsMap(java.lang.Object bean)
Return a Java Map of all read-write properties of the specified Java bean.
public static void setPropertiesFromMap(java.lang.Object bean, java.util.Map<java.lang.String,java.lang.Object> properties)
public static java.lang.Object getProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop)
getProperty(Object, String)
, but use a supplied
PropertyDescriptor
instead of the property name.public static java.lang.Object getProperty(java.lang.Object bean, java.lang.String propname, int index)
bean
- An object conforming to the Java Beans Specification.propname
- The name of the desired bean property.index
- The integer
index within the property. If the
value is negative, the property itself is returned. That is,
for example, if the property is String [] values
and if index
is < 0, values
will be
returned, otherwise values[index]
will be
returned.HGException
- if the property cannot be found in the bean or if
index >= 0
and the property is not an indexed
property.public static java.lang.Object getProperty(java.lang.Object bean, java.lang.String propname)
bean
- An object conforming to the Java Beans Specification.propname
- The name of the desired bean property.HGException
- if the property cannot be found in the bean or if
index >= 0
and the property is not an indexed
property.public static void setProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop, int index, java.lang.Object newvalue)
setProperty(Object, String, int, Object)
, but use a
supplied PropertyDescriptor
instead of the property name.public static void setProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop, java.lang.Object newvalue)
setProperty(Object, String, Object)
, but use a
supplied PropertyDescriptor
instead of the property name.public static void setProperty(java.lang.Object bean, java.lang.String propname, int index, java.lang.Object newvalue)
bean
- An object conforming to the Java Beans Specification.propname
- The name of the desired bean property.index
- The integer
index within the property. If the
value is negative, the property itself will be modified. That
is, for example, if the property is
String [] values
and if index
is <
0, values
will be modified, otherwise
values[index]
will be modified.newvalue
- The value to assign to the specified property.HGException
- if the property cannot be found in the bean or if
index >= 0
and the property is not an indexed
property.public static void setProperty(java.lang.Object bean, java.lang.String propname, java.lang.Object newvalue)
bean
- An object conforming to the Java Beans Specification.propname
- The name of the desired bean property.newvalue
- The value to assign to the specified property.HGException
- if the property cannot be found in the bean or if
index >= 0
and the property is not an indexed
property.public static java.lang.Object makeBean(java.lang.String classname)
classname
- The fully qualified class name of the bean to construct.HGException
- is there's any error during the construction process, such as
ClassNotFoundException etc.public static java.lang.Class<?> primitiveEquivalentOf(java.lang.Class<?> aClass)
aClass
- a Classpublic static java.lang.Class<?> wrapperEquivalentOf(java.lang.Class<?> aClass)