Class DefaultBeanIntrospector

  • All Implemented Interfaces:
    BeanIntrospector

    public class DefaultBeanIntrospector
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.Class<?>[] EMPTY_CLASS_PARAMETERS
      Constant for argument types of a method that expects no arguments.
      static BeanIntrospector INSTANCE
      The singleton instance of this class.
      private static java.lang.Class<?>[] LIST_CLASS_PARAMETER
      Constant for arguments types of a method that expects a list argument.
      private org.apache.commons.logging.Log log
      Log instance
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DefaultBeanIntrospector()
      Private constructor so that no instances can be created.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void handleIndexedPropertyDescriptors​(java.lang.Class<?> beanClass, java.beans.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).
      void introspect​(IntrospectionContext icontext)
      Performs introspection of a specific Java class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INSTANCE

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

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

        private static final java.lang.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 Detail

      • DefaultBeanIntrospector

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

      • 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​(java.lang.Class<?> beanClass,
                                                      java.beans.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