Class DefaultBeanIntrospector

java.lang.Object
org.apache.commons.beanutils.DefaultBeanIntrospector
All Implemented Interfaces:
BeanIntrospector

public class DefaultBeanIntrospector extends Object implements BeanIntrospector

The default BeanIntrospector implementation.

This class implements a default bean introspection algorithm based on the JDK classes in the java.beans package. It discovers properties conforming to the Java Beans specification.

This class is a singleton. The single instance can be obtained using the INSTANCE field. It does not define any state and thus can be shared by arbitrary clients. PropertyUtils per default uses this instance as its only BeanIntrospector object.

Since:
1.9
Version:
$Id$
  • Field Details

    • INSTANCE

      public static final BeanIntrospector INSTANCE
      The singleton instance of this class.
    • EMPTY_CLASS_PARAMETERS

      private static final Class<?>[] EMPTY_CLASS_PARAMETERS
      Constant for argument types of a method that expects no arguments.
    • LIST_CLASS_PARAMETER

      private static final Class<?>[] LIST_CLASS_PARAMETER
      Constant for arguments types of a method that expects a list argument.
    • log

      private final org.apache.commons.logging.Log log
      Log instance
  • Constructor Details

    • DefaultBeanIntrospector

      private DefaultBeanIntrospector()
      Private constructor so that no instances can be created.
  • Method Details

    • introspect

      public void introspect(IntrospectionContext icontext)
      Performs introspection of a specific Java class. This implementation uses the java.beans.Introspector.getBeanInfo() method to obtain all property descriptors for the current class and adds them to the passed in introspection context.
      Specified by:
      introspect in interface BeanIntrospector
      Parameters:
      icontext - the introspection context
    • handleIndexedPropertyDescriptors

      private void handleIndexedPropertyDescriptors(Class<?> beanClass, PropertyDescriptor[] descriptors)
      This method fixes an issue where IndexedPropertyDescriptor behaves differently in different versions of the JDK for 'indexed' properties which use java.util.List (rather than an array). It implements a workaround for Bug 28358. If you have a Bean with the following getters/setters for an indexed property:
       public List getFoo()
       public Object getFoo(int index)
       public void setFoo(List foo)
       public void setFoo(int index, Object foo)
       
      then the IndexedPropertyDescriptor's getReadMethod() and getWriteMethod() behave as follows:
      • JDK 1.3.1_04: returns valid Method objects from these methods.
      • JDK 1.4.2_05: returns null from these methods.
      Parameters:
      beanClass - the current class to be inspected
      descriptors - the array with property descriptors