|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.cosylab.introspection.BeanIntrospector
public class BeanIntrospector
The BeanIntrospector class helps read and write property values from a Java Bean and provides methods for easier manipulation of PropertyDescriptor arrays.
Constructor Summary | |
---|---|
BeanIntrospector()
|
Method Summary | |
---|---|
static java.beans.FeatureDescriptor |
getDescriptor(java.beans.FeatureDescriptor[] descriptors,
java.lang.reflect.Member m)
Retrieves the FeatureDescriptor for a member from an array
of FeatureDescriptor s. |
static java.beans.FeatureDescriptor |
getDescriptorByName(java.beans.FeatureDescriptor[] descriptors,
java.lang.String featureName)
Retrieves the FeatureDescriptor for a member from an array
of FeatureDescriptor s given the feature's name. |
static java.beans.PropertyDescriptor[] |
getInterfacePropertyDescriptors(java.lang.Class theClass,
java.lang.Class superInterface)
Returns descriptors of the properties declared in interfaces that the current class implements, following the interface hierarchy to the superInterface specified. |
static java.util.Map |
getProperties(java.lang.Object target)
Returns a Name-Value map of all the properties on a given object |
static java.util.Map |
getProperties(java.beans.PropertyDescriptor[] properties,
java.lang.Object target)
Returns a Name-Value map of properties described by the array of type PropertyDescriptor s; Values are retrieved from the
target object. |
static java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.Class beanClass,
java.lang.String propertyName)
Returns descriptor for the property with specified property name of bean with beanClass |
static java.beans.PropertyDescriptor[] |
getPropertyDescriptors(java.lang.Class theClass)
Returns all the property descriptors of theClass . |
static java.lang.String |
getPropertyDisplayString(java.lang.String propertyName)
DOCUMENT ME! |
static java.lang.String |
getPropertyDisplayString(java.lang.String propertyName,
boolean titleCase)
DOCUMENT ME! |
static java.lang.String[] |
getPropertyNames(java.beans.PropertyDescriptor[] desc)
Returns names of all the property desriptors in the given array. |
static java.lang.Class |
getPropertyType(java.lang.Class beanClass,
java.lang.String propertyName)
Returns the type of the specified property on specified bean. |
static java.lang.Class[] |
getPropertyTypes(java.beans.PropertyDescriptor[] desc)
Returns types of all the property descriptors in the given array. |
static java.lang.Object |
getPropertyValue(java.lang.Object target,
java.lang.String propertyName)
Gets the value of the property specified by propertyName
on the target object. |
static java.lang.Object[] |
getPropertyValues(java.beans.PropertyDescriptor[] desc,
java.lang.Object target)
Returns types of all the property descriptors in the given array. |
static java.beans.PropertyDescriptor[] |
getReadable(java.beans.PropertyDescriptor[] desc)
Selects descriptors of all readable properties from an array of descriptors. |
static java.lang.reflect.Method |
getSetterMethod(java.lang.Class inspectedBean,
java.lang.String propertyName)
Gets a setter method for a property specified by propertyName |
static java.beans.PropertyDescriptor[] |
getWritable(java.beans.PropertyDescriptor[] desc)
Selects descriptors of all writable properties from an array of descriptors. |
static boolean |
isGetterMethod(java.lang.reflect.Method method)
DOCUMENT ME! |
static void |
setPropertyValue(java.lang.Object target,
java.lang.String propertyName,
java.lang.Object value)
Sets the value of the specified property on the target
object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BeanIntrospector()
Method Detail |
---|
public static java.lang.Object getPropertyValue(java.lang.Object target, java.lang.String propertyName) throws java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
propertyName
on the target
object. Primitive types are returned in
equivalent Java objects.
target
- the object containing the propertypropertyName
- the name of the property to get
java.beans.IntrospectionException
- if an illegal property name is
specified or the target object is not a Java bean
java.lang.reflect.InvocationTargetException
- when an exception is
thrown inside the property getter
java.lang.IllegalAccessException
- when property access is restricted on the
target objectpublic static java.util.Map getProperties(java.lang.Object target) throws java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
target
- Object
java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.NullPointerException
- DOCUMENT ME!public static java.util.Map getProperties(java.beans.PropertyDescriptor[] properties, java.lang.Object target) throws java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
PropertyDescriptor
s; Values are retrieved from the
target
object.
properties
- PropertyDescriptor[]target
- Object
java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
public static void setPropertyValue(java.lang.Object target, java.lang.String propertyName, java.lang.Object value) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
target
object.
target
- the object containing the propertypropertyName
- name of the propertyvalue
- the new value of the property
java.lang.NoSuchMethodException
- if the setter does not exist
java.lang.reflect.InvocationTargetException
- reflection exception
java.lang.IllegalAccessException
- reflection exceptionpublic static java.lang.reflect.Method getSetterMethod(java.lang.Class inspectedBean, java.lang.String propertyName)
inspectedBean
- ClasspropertyName
- String
public static java.beans.FeatureDescriptor getDescriptor(java.beans.FeatureDescriptor[] descriptors, java.lang.reflect.Member m)
FeatureDescriptor
for a member from an array
of FeatureDescriptor
s. Member should be the method that is
desribed by a MethodDescriptor or the read method of a property
described by PropertyDescriptor.
descriptors
- PropertyDescriptor[]m
- String
public static java.beans.FeatureDescriptor getDescriptorByName(java.beans.FeatureDescriptor[] descriptors, java.lang.String featureName)
FeatureDescriptor
for a member from an array
of FeatureDescriptor
s given the feature's name. Feature
can be a property, a method, or an event set.
descriptors
- FeatureDescriptor[]featureName
- String
public static java.beans.PropertyDescriptor[] getInterfacePropertyDescriptors(java.lang.Class theClass, java.lang.Class superInterface)
superInterface
specified. Descriptors of properties that
are declared in the class itself or an interface, that is not a
descendant of the specified interface, are not returned.
theClass
- ClasssuperInterface
- Class
public static java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.Class beanClass, java.lang.String propertyName) throws java.beans.IntrospectionException
beanClass
beanClass
- the Class of the bean to introspectpropertyName
- the property name
java.beans.IntrospectionException
public static java.lang.Class getPropertyType(java.lang.Class beanClass, java.lang.String propertyName) throws java.beans.IntrospectionException
beanClass
- the Class of the bean to introspectpropertyName
- the property name
java.beans.IntrospectionException
public static java.lang.String[] getPropertyNames(java.beans.PropertyDescriptor[] desc)
desc
- PropertyDescriptor[]
public static java.lang.Class[] getPropertyTypes(java.beans.PropertyDescriptor[] desc)
desc
- PropertyDescriptor[]
public static java.lang.Object[] getPropertyValues(java.beans.PropertyDescriptor[] desc, java.lang.Object target) throws java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
desc
- PropertyDescriptor[]target
- DOCUMENT ME!
java.beans.IntrospectionException
- DOCUMENT ME!
java.lang.reflect.InvocationTargetException
- DOCUMENT ME!
java.lang.IllegalAccessException
- DOCUMENT ME!public static java.beans.PropertyDescriptor[] getWritable(java.beans.PropertyDescriptor[] desc)
desc
- PropertyDescriptor[]
public static java.beans.PropertyDescriptor[] getReadable(java.beans.PropertyDescriptor[] desc)
desc
- PropertyDescriptor[]
public static java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Class theClass) throws java.beans.IntrospectionException
theClass
.
theClass
- Class
java.beans.IntrospectionException
public static java.lang.String getPropertyDisplayString(java.lang.String propertyName)
propertyName
- DOCUMENT ME!
public static java.lang.String getPropertyDisplayString(java.lang.String propertyName, boolean titleCase)
propertyName
- DOCUMENT ME!titleCase
- DOCUMENT ME!
public static boolean isGetterMethod(java.lang.reflect.Method method)
method
- DOCUMENT ME!
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |