class DefaultIntrospectionContext extends java.lang.Object implements 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.
Modifier and Type | Field and Description |
---|---|
private java.lang.Class<?> |
currentClass
The current class for introspection.
|
private java.util.Map<java.lang.String,java.beans.PropertyDescriptor> |
descriptors
A map for storing the already added property descriptors.
|
private static java.beans.PropertyDescriptor[] |
EMPTY_DESCRIPTORS
Constant for an empty array of property descriptors.
|
Constructor and Description |
---|
DefaultIntrospectionContext(java.lang.Class<?> cls)
Creates a new instance of
DefaultIntrospectionContext and sets
the current class for introspection. |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyDescriptor(java.beans.PropertyDescriptor desc)
Adds the given property descriptor to this context.
|
void |
addPropertyDescriptors(java.beans.PropertyDescriptor[] descs)
Adds an array of property descriptors to this context.
|
java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.String name)
Returns the descriptor for the property with the given name or
null if this property is unknown.
|
java.beans.PropertyDescriptor[] |
getPropertyDescriptors()
Returns an array with all descriptors added to this context.
|
java.lang.Class<?> |
getTargetClass()
Returns the class that is subject of introspection.
|
boolean |
hasProperty(java.lang.String name)
Tests whether a descriptor for the property with the given name is
already contained in this context.
|
java.util.Set<java.lang.String> |
propertyNames()
Returns a set with the names of all properties known to this context.
|
void |
removePropertyDescriptor(java.lang.String name)
Removes the descriptor for the property with the given name.
|
private static final java.beans.PropertyDescriptor[] EMPTY_DESCRIPTORS
private final java.lang.Class<?> currentClass
private final java.util.Map<java.lang.String,java.beans.PropertyDescriptor> descriptors
public DefaultIntrospectionContext(java.lang.Class<?> cls)
DefaultIntrospectionContext
and sets
the current class for introspection.cls
- the current classpublic java.lang.Class<?> getTargetClass()
IntrospectionContext
getTargetClass
in interface IntrospectionContext
public void addPropertyDescriptor(java.beans.PropertyDescriptor desc)
IntrospectionContext
BeanIntrospector
during introspection for each detected
property. If this context already contains a descriptor for the affected
property, it is overridden.addPropertyDescriptor
in interface IntrospectionContext
desc
- the property descriptorpublic void addPropertyDescriptors(java.beans.PropertyDescriptor[] descs)
IntrospectionContext
addPropertyDescriptors
in interface IntrospectionContext
descs
- the array of descriptors to be addedpublic boolean hasProperty(java.lang.String name)
IntrospectionContext
hasProperty
in interface IntrospectionContext
name
- the name of the property in questionpublic java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String name)
IntrospectionContext
getPropertyDescriptor
in interface IntrospectionContext
name
- the name of the property in questionpublic void removePropertyDescriptor(java.lang.String name)
IntrospectionContext
removePropertyDescriptor
in interface IntrospectionContext
name
- the name of the affected propertypublic java.util.Set<java.lang.String> propertyNames()
IntrospectionContext
propertyNames
in interface IntrospectionContext
public java.beans.PropertyDescriptor[] getPropertyDescriptors()
Copyright (c) 2000-2008 - Apache Software Foundation