Package org.apache.commons.beanutils
Class BeanIntrospectionData
java.lang.Object
org.apache.commons.beanutils.BeanIntrospectionData
An internally used helper class for storing introspection information about a bean class.
This class is used by PropertyUtilsBean
. When accessing bean properties via
reflection information about the properties available and their types and access
methods must be present. PropertyUtilsBean
stores this information in a cache
so that it can be accessed quickly. The cache stores instances of this class.
This class mainly stores information about the properties of a bean class. Per default,
this is contained in PropertyDescriptor
objects. Some additional information
required by the BeanUtils
library is also stored here.
- Since:
- 1.9.1
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PropertyDescriptor[]
An array with property descriptors for the managed bean class.A map for remembering the write method names for properties. -
Constructor Summary
ConstructorsConstructorDescriptionBeanIntrospectionData
(PropertyDescriptor[] descs) Creates a new instance ofBeanIntrospectionData
and initializes its completely.BeanIntrospectionData
(PropertyDescriptor[] descs, Map<String, String> writeMethNames) Creates a new instance ofBeanIntrospectionData
and allows setting the map with write method names. -
Method Summary
Modifier and TypeMethodDescriptiongetDescriptor
(String name) Returns thePropertyDescriptor
for the property with the specified name.Returns the array with property descriptors.getWriteMethod
(Class<?> beanCls, PropertyDescriptor desc) Returns the write method for the property determined by the givenPropertyDescriptor
.setUpWriteMethodNames
(PropertyDescriptor[] descs) Initializes the map with the names of the write methods for the supported properties.
-
Field Details
-
descriptors
An array with property descriptors for the managed bean class. -
writeMethodNames
A map for remembering the write method names for properties.
-
-
Constructor Details
-
BeanIntrospectionData
Creates a new instance ofBeanIntrospectionData
and initializes its completely.- Parameters:
descs
- the array with the descriptors of the available properties
-
BeanIntrospectionData
BeanIntrospectionData(PropertyDescriptor[] descs, Map<String, String> writeMethNames) Creates a new instance ofBeanIntrospectionData
and allows setting the map with write method names. This constructor is mainly used for testing purposes.- Parameters:
descs
- the array with the descriptors of the available propertieswriteMethNames
- the map with the names of write methods
-
-
Method Details
-
getDescriptors
Returns the array with property descriptors.- Returns:
- the property descriptors for the associated bean class
-
getDescriptor
Returns thePropertyDescriptor
for the property with the specified name. If this property is unknown, result is null.- Parameters:
name
- the name of the property in question- Returns:
- the
PropertyDescriptor
for this property or null
-
getWriteMethod
Returns the write method for the property determined by the givenPropertyDescriptor
. This information is normally available in the descriptor object itself. However, at least by the ORACLE implementation, the method is stored as aSoftReference
. If this reference has been freed by the GC, it may be the case that the method cannot be obtained again. Then, additional information stored in this object is necessary to obtain the method again.- Parameters:
beanCls
- the class of the affected beandesc
- thePropertyDescriptor
of the desired property- Returns:
- the write method for this property or null if there is none
-
setUpWriteMethodNames
Initializes the map with the names of the write methods for the supported properties. The method names - if defined - need to be stored separately because they may get lost when the GC claims soft references used by thePropertyDescriptor
objects.- Parameters:
descs
- the array with the descriptors of the available properties- Returns:
- the map with the names of write methods for properties
-