Package org.apache.commons.beanutils
Class DefaultBeanIntrospector
- java.lang.Object
-
- org.apache.commons.beanutils.DefaultBeanIntrospector
-
- All Implemented Interfaces:
BeanIntrospector
public class DefaultBeanIntrospector extends java.lang.Object implements BeanIntrospector
The default
BeanIntrospectorimplementation.This class implements a default bean introspection algorithm based on the JDK classes in the
java.beanspackage. It discovers properties conforming to the Java Beans specification.This class is a singleton. The single instance can be obtained using the
INSTANCEfield. It does not define any state and thus can be shared by arbitrary clients.PropertyUtilsper default uses this instance as its onlyBeanIntrospectorobject.- Since:
- 1.9
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Class<?>[]EMPTY_CLASS_PARAMETERSConstant for argument types of a method that expects no arguments.static BeanIntrospectorINSTANCEThe singleton instance of this class.private static java.lang.Class<?>[]LIST_CLASS_PARAMETERConstant for arguments types of a method that expects a list argument.private org.apache.commons.logging.LoglogLog instance
-
Constructor Summary
Constructors Modifier Constructor Description privateDefaultBeanIntrospector()Private constructor so that no instances can be created.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidhandleIndexedPropertyDescriptors(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).voidintrospect(IntrospectionContext icontext)Performs introspection of a specific Java class.
-
-
-
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
-
-
Method Detail
-
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 inspecteddescriptors- the array with property descriptors
-
introspect
public void introspect(IntrospectionContext icontext)
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
-
-