Package org.apache.commons.beanutils
Class DefaultIntrospectionContext
java.lang.Object
org.apache.commons.beanutils.DefaultIntrospectionContext
- All Implemented Interfaces:
IntrospectionContext
An implementation of the IntrospectionContext
interface used by
PropertyUtilsBean
when doing introspection of a bean class.
This class implements the methods required by the
IntrospectionContext
interface in a straight-forward manner
based on a map. It is used internally only. It is not thread-safe.
- Since:
- 1.9
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class
<?> The current class for introspection.private final Map
<String, PropertyDescriptor> A map for storing the already added property descriptors.private static final PropertyDescriptor[]
Constant for an empty array of property descriptors. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultIntrospectionContext
(Class<?> cls) Creates a new instance ofDefaultIntrospectionContext
and sets the current class for introspection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given property descriptor to this context.void
addPropertyDescriptors
(PropertyDescriptor[] descs) Adds an array of property descriptors to this context.getPropertyDescriptor
(String name) Returns the descriptor for the property with the given name or null if this property is unknown.Returns an array with all descriptors added to this context.Class
<?> Returns the class that is subject of introspection.boolean
hasProperty
(String name) Tests whether a descriptor for the property with the given name is already contained in this context.Returns a set with the names of all properties known to this context.void
Removes the descriptor for the property with the given name.
-
Field Details
-
EMPTY_DESCRIPTORS
Constant for an empty array of property descriptors. -
currentClass
The current class for introspection. -
descriptors
A map for storing the already added property descriptors.
-
-
Constructor Details
-
DefaultIntrospectionContext
Creates a new instance ofDefaultIntrospectionContext
and sets the current class for introspection.- Parameters:
cls
- the current class
-
-
Method Details
-
getTargetClass
Description copied from interface:IntrospectionContext
Returns the class that is subject of introspection.- Specified by:
getTargetClass
in interfaceIntrospectionContext
- Returns:
- the current class
-
addPropertyDescriptor
Description copied from interface:IntrospectionContext
Adds the given property descriptor to this context. This method is called by aBeanIntrospector
during introspection for each detected property. If this context already contains a descriptor for the affected property, it is overridden.- Specified by:
addPropertyDescriptor
in interfaceIntrospectionContext
- Parameters:
desc
- the property descriptor
-
addPropertyDescriptors
Description copied from interface:IntrospectionContext
Adds an array of property descriptors to this context. Using this method multiple descriptors can be added at once.- Specified by:
addPropertyDescriptors
in interfaceIntrospectionContext
- Parameters:
descs
- the array of descriptors to be added
-
hasProperty
Description copied from interface:IntrospectionContext
Tests whether a descriptor for the property with the given name is already contained in this context. This method can be used for instance to prevent that an already existing property descriptor is overridden.- Specified by:
hasProperty
in interfaceIntrospectionContext
- Parameters:
name
- the name of the property in question- Returns:
- true if a descriptor for this property has already been added, false otherwise
-
getPropertyDescriptor
Description copied from interface:IntrospectionContext
Returns the descriptor for the property with the given name or null if this property is unknown.- Specified by:
getPropertyDescriptor
in interfaceIntrospectionContext
- Parameters:
name
- the name of the property in question- Returns:
- the descriptor for this property or null if this property is unknown
-
removePropertyDescriptor
Description copied from interface:IntrospectionContext
Removes the descriptor for the property with the given name.- Specified by:
removePropertyDescriptor
in interfaceIntrospectionContext
- Parameters:
name
- the name of the affected property
-
propertyNames
Description copied from interface:IntrospectionContext
Returns a set with the names of all properties known to this context.- Specified by:
propertyNames
in interfaceIntrospectionContext
- Returns:
- a set with the known property names
-
getPropertyDescriptors
Returns an array with all descriptors added to this context. This method is used to obtain the results of introspection.- Returns:
- an array with all known property descriptors
-