Class DefaultBeanIntrospector
java.lang.Object
org.apache.commons.beanutils.DefaultBeanIntrospector
- All Implemented Interfaces:
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Class<?>[]Constant for argument types of a method that expects no arguments.static final BeanIntrospectorThe singleton instance of this class.private static final Class<?>[]Constant for arguments types of a method that expects a list argument.private final org.apache.commons.logging.LogLog instance -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor so that no instances can be created. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidhandleIndexedPropertyDescriptors(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).voidintrospect(IntrospectionContext icontext) Performs introspection of a specific Java class.
-
Field Details
-
INSTANCE
The singleton instance of this class. -
EMPTY_CLASS_PARAMETERS
Constant for argument types of a method that expects no arguments. -
LIST_CLASS_PARAMETER
Constant for arguments types of a method that expects a list argument. -
log
private final org.apache.commons.logging.Log logLog instance
-
-
Constructor Details
-
DefaultBeanIntrospector
private DefaultBeanIntrospector()Private constructor so that no instances can be created.
-
-
Method Details
-
handleIndexedPropertyDescriptors
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 inspecteddescriptors- the array with property descriptors
-
introspect
Performs introspection of a specific Java class. This implementation uses thejava.beans.Introspector.getBeanInfo()method to obtain all property descriptors for the current class and adds them to the passed in introspection context.- Specified by:
introspectin interfaceBeanIntrospector- Parameters:
icontext- the introspection context
-