Class BeanIntrospectionData

java.lang.Object
org.apache.commons.beanutils.BeanIntrospectionData

class BeanIntrospectionData extends 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 the BeanUtils library is also stored here.

Since:
1.9.1
Version:
$Id$
  • Field Details

    • descriptors

      private final PropertyDescriptor[] descriptors
      An array with property descriptors for the managed bean class.
    • writeMethodNames

      private final Map<String,String> writeMethodNames
      A map for remembering the write method names for properties.
  • Constructor Details

    • BeanIntrospectionData

      public BeanIntrospectionData(PropertyDescriptor[] descs)
      Creates a new instance of BeanIntrospectionData 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 of BeanIntrospectionData 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 properties
      writeMethNames - the map with the names of write methods
  • Method Details

    • getDescriptors

      public PropertyDescriptor[] getDescriptors()
      Returns the array with property descriptors.
      Returns:
      the property descriptors for the associated bean class
    • getDescriptor

      public PropertyDescriptor getDescriptor(String name)
      Returns the PropertyDescriptor 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 Method getWriteMethod(Class<?> beanCls, PropertyDescriptor desc)
      Returns the write method for the property determined by the given PropertyDescriptor. This information is normally available in the descriptor object itself. However, at least by the ORACLE implementation, the method is stored as a SoftReference. 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 bean
      desc - the PropertyDescriptor of the desired property
      Returns:
      the write method for this property or null if there is none
    • setUpWriteMethodNames

      private static Map<String,String> setUpWriteMethodNames(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 the PropertyDescriptor objects.
      Parameters:
      descs - the array with the descriptors of the available properties
      Returns:
      the map with the names of write methods for properties