Package org.apache.commons.beanutils
Class BeanIntrospectionData
- java.lang.Object
-
- org.apache.commons.beanutils.BeanIntrospectionData
-
class BeanIntrospectionData extends java.lang.Object
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 theBeanUtils
library is also stored here.- Since:
- 1.9.1
- Version:
- $Id: BeanIntrospectionData.java 1555233 2014-01-03 19:41:04Z oheger $
-
-
Field Summary
Fields Modifier and Type Field Description private java.beans.PropertyDescriptor[]
descriptors
An array with property descriptors for the managed bean class.private java.util.Map<java.lang.String,java.lang.String>
writeMethodNames
A map for remembering the write method names for properties.
-
Constructor Summary
Constructors Constructor Description BeanIntrospectionData(java.beans.PropertyDescriptor[] descs)
Creates a new instance ofBeanIntrospectionData
and initializes its completely.BeanIntrospectionData(java.beans.PropertyDescriptor[] descs, java.util.Map<java.lang.String,java.lang.String> writeMethNames)
Creates a new instance ofBeanIntrospectionData
and allows setting the map with write method names.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.beans.PropertyDescriptor
getDescriptor(java.lang.String name)
Returns thePropertyDescriptor
for the property with the specified name.java.beans.PropertyDescriptor[]
getDescriptors()
Returns the array with property descriptors.java.lang.reflect.Method
getWriteMethod(java.lang.Class<?> beanCls, java.beans.PropertyDescriptor desc)
Returns the write method for the property determined by the givenPropertyDescriptor
.private static java.util.Map<java.lang.String,java.lang.String>
setUpWriteMethodNames(java.beans.PropertyDescriptor[] descs)
Initializes the map with the names of the write methods for the supported properties.
-
-
-
Field Detail
-
descriptors
private final java.beans.PropertyDescriptor[] descriptors
An array with property descriptors for the managed bean class.
-
writeMethodNames
private final java.util.Map<java.lang.String,java.lang.String> writeMethodNames
A map for remembering the write method names for properties.
-
-
Constructor Detail
-
BeanIntrospectionData
public BeanIntrospectionData(java.beans.PropertyDescriptor[] descs)
Creates a new instance ofBeanIntrospectionData
and initializes its completely.- Parameters:
descs
- the array with the descriptors of the available properties
-
BeanIntrospectionData
BeanIntrospectionData(java.beans.PropertyDescriptor[] descs, java.util.Map<java.lang.String,java.lang.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 Detail
-
getDescriptors
public java.beans.PropertyDescriptor[] getDescriptors()
Returns the array with property descriptors.- Returns:
- the property descriptors for the associated bean class
-
getDescriptor
public java.beans.PropertyDescriptor getDescriptor(java.lang.String name)
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
public java.lang.reflect.Method getWriteMethod(java.lang.Class<?> beanCls, java.beans.PropertyDescriptor desc)
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
private static java.util.Map<java.lang.String,java.lang.String> setUpWriteMethodNames(java.beans.PropertyDescriptor[] descs)
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
-
-