org.apache.commons.beanutils
public class MappedPropertyDescriptor extends java.beans.PropertyDescriptor
where getProperty(String key)
and
set<Property>(String key, Object value)
,
Property
must be replaced
by the name of the property.
PropertyDescriptor
Modifier and Type | Field and Description |
---|---|
private static java.util.Hashtable |
declaredMethodCache |
private java.lang.Class |
mappedPropertyType
The underlying data type of the property we are describing.
|
private java.lang.reflect.Method |
mappedReadMethod
The reader method for this property (if any).
|
private java.lang.reflect.Method |
mappedWriteMethod
The writer method for this property (if any).
|
private static java.lang.Class[] |
stringClassArray
The parameter types array for the reader method signature.
|
Constructor and Description |
---|
MappedPropertyDescriptor(java.lang.String propertyName,
java.lang.Class beanClass)
Constructs a MappedPropertyDescriptor for a property that follows
the standard Java convention by having getFoo and setFoo
accessor methods, with the addition of a String parameter (the key).
|
MappedPropertyDescriptor(java.lang.String propertyName,
java.lang.Class beanClass,
java.lang.String mappedGetterName,
java.lang.String mappedSetterName)
This constructor takes the name of a mapped property, and method
names for reading and writing the property.
|
MappedPropertyDescriptor(java.lang.String propertyName,
java.lang.reflect.Method mappedGetter,
java.lang.reflect.Method mappedSetter)
This constructor takes the name of a mapped property, and Method
objects for reading and writing the property.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
capitalizePropertyName(java.lang.String s)
Return a capitalized version of the specified property name.
|
private void |
findMappedPropertyType()
Introspect our bean class to identify the corresponding getter
and setter methods.
|
(package private) static java.lang.reflect.Method |
findMethod(java.lang.Class cls,
java.lang.String methodName,
int argCount)
Find a target methodName on a given class.
|
(package private) static java.lang.reflect.Method |
findMethod(java.lang.Class cls,
java.lang.String methodName,
int argCount,
java.lang.Class[] args)
Find a target methodName with specific parameter list on a given class.
|
java.lang.Class |
getMappedPropertyType()
Gets the Class object for the property values.
|
java.lang.reflect.Method |
getMappedReadMethod()
Gets the method that should be used to read one of the property value.
|
java.lang.reflect.Method |
getMappedWriteMethod()
Gets the method that should be used to write one of the property value.
|
private static java.lang.reflect.Method[] |
getPublicDeclaredMethods(java.lang.Class clz) |
private static java.lang.reflect.Method |
internalFindMethod(java.lang.Class start,
java.lang.String methodName,
int argCount)
Internal support for finding a target methodName on a given class.
|
private static java.lang.reflect.Method |
internalFindMethod(java.lang.Class start,
java.lang.String methodName,
int argCount,
java.lang.Class[] args)
Internal support for finding a target methodName with a given
parameter list on a given class.
|
(package private) static boolean |
isSubclass(java.lang.Class a,
java.lang.Class b)
Return true if class a is either equivalent to class b, or
if class a is a subclass of class b, ie if a either "extends"
or "implements" b.
|
void |
setMappedReadMethod(java.lang.reflect.Method mappedGetter)
Sets the method that should be used to read one of the property value.
|
void |
setMappedWriteMethod(java.lang.reflect.Method mappedSetter)
Sets the method that should be used to write the property value.
|
private boolean |
throwsException(java.lang.reflect.Method method,
java.lang.Class exception)
Return true iff the given method throws the given exception.
|
createPropertyEditor, equals, getPropertyEditorClass, getPropertyType, getReadMethod, getWriteMethod, hashCode, isBound, isConstrained, setBound, setConstrained, setPropertyEditorClass, setReadMethod, setWriteMethod
private java.lang.Class mappedPropertyType
private java.lang.reflect.Method mappedReadMethod
private java.lang.reflect.Method mappedWriteMethod
private static final java.lang.Class[] stringClassArray
private static java.util.Hashtable declaredMethodCache
public MappedPropertyDescriptor(java.lang.String propertyName, java.lang.Class beanClass) throws java.beans.IntrospectionException
propertyName
- The programmatic name of the property.beanClass
- The Class object for the target bean. For
example sun.beans.OurButton.class.java.beans.IntrospectionException
- if an exception occurs during
introspection.public MappedPropertyDescriptor(java.lang.String propertyName, java.lang.Class beanClass, java.lang.String mappedGetterName, java.lang.String mappedSetterName) throws java.beans.IntrospectionException
propertyName
- The programmatic name of the property.beanClass
- The Class object for the target bean. For
example sun.beans.OurButton.class.mappedGetterName
- The name of the method used for
reading one of the property values. May be null if the
property is write-only.mappedSetterName
- The name of the method used for writing
one of the property values. May be null if the property is
read-only.java.beans.IntrospectionException
- if an exception occurs during
introspection.public MappedPropertyDescriptor(java.lang.String propertyName, java.lang.reflect.Method mappedGetter, java.lang.reflect.Method mappedSetter) throws java.beans.IntrospectionException
propertyName
- The programmatic name of the property.mappedGetter
- The method used for reading one of
the property values. May be be null if the property
is write-only.mappedSetter
- The method used for writing one the
property values. May be null if the property is read-only.java.beans.IntrospectionException
- if an exception occurs during
introspection.public java.lang.Class getMappedPropertyType()
This is the type that will be returned by the mappedReadMethod.
public java.lang.reflect.Method getMappedReadMethod()
public void setMappedReadMethod(java.lang.reflect.Method mappedGetter) throws java.beans.IntrospectionException
mappedGetter
- The new getter method.java.beans.IntrospectionException
public java.lang.reflect.Method getMappedWriteMethod()
public void setMappedWriteMethod(java.lang.reflect.Method mappedSetter) throws java.beans.IntrospectionException
mappedSetter
- The new setter method.java.beans.IntrospectionException
private void findMappedPropertyType() throws java.beans.IntrospectionException
java.beans.IntrospectionException
private static java.lang.String capitalizePropertyName(java.lang.String s)
s
- The property nameprivate static java.lang.reflect.Method[] getPublicDeclaredMethods(java.lang.Class clz)
private static java.lang.reflect.Method internalFindMethod(java.lang.Class start, java.lang.String methodName, int argCount)
private static java.lang.reflect.Method internalFindMethod(java.lang.Class start, java.lang.String methodName, int argCount, java.lang.Class[] args)
static java.lang.reflect.Method findMethod(java.lang.Class cls, java.lang.String methodName, int argCount) throws java.beans.IntrospectionException
java.beans.IntrospectionException
static java.lang.reflect.Method findMethod(java.lang.Class cls, java.lang.String methodName, int argCount, java.lang.Class[] args) throws java.beans.IntrospectionException
java.beans.IntrospectionException
static boolean isSubclass(java.lang.Class a, java.lang.Class b)
private boolean throwsException(java.lang.reflect.Method method, java.lang.Class exception)
Copyright (c) 2001-2004 - Apache Software Foundation