public class Introspector
extends java.lang.Object
Finding methods as well as property getters & setters.
Modifier and Type | Field and Description |
---|---|
private java.lang.ref.SoftReference<IntrospectorBase> |
ref
The soft reference to the introspector currently in use.
|
protected org.apache.commons.logging.Log |
rlog
The logger to use for all warnings & errors.
|
Modifier | Constructor and Description |
---|---|
protected |
Introspector(org.apache.commons.logging.Log log)
Creates an introspector.
|
Modifier and Type | Method and Description |
---|---|
protected IntrospectorBase |
base()
Gets the current introspector base.
|
java.lang.Class<?> |
getClassByName(java.lang.String className)
Gets a class by name through this introspector class loader.
|
java.lang.reflect.Constructor<?> |
getConstructor(java.lang.Object ctorHandle,
java.lang.Object[] args)
Returns a general constructor.
|
java.lang.reflect.Field |
getField(java.lang.Class<?> c,
java.lang.String key)
Gets the field named by
key for the class c . |
java.lang.String[] |
getFieldNames(java.lang.Class<?> c)
Gets the accessible field names known for a given class.
|
AbstractExecutor.Get |
getGetExecutor(java.lang.Object obj,
java.lang.Object identifier)
Return a property getter.
|
java.lang.reflect.Method |
getMethod(java.lang.Class<?> c,
MethodKey key)
Gets the method defined by
key and for the Class c . |
java.lang.reflect.Method |
getMethod(java.lang.Class<?> c,
java.lang.String name,
java.lang.Object[] params)
Gets the method defined by
name and
params for the Class c . |
AbstractExecutor.Method |
getMethodExecutor(java.lang.Object obj,
java.lang.String name,
java.lang.Object[] args)
Returns a general method.
|
java.lang.String[] |
getMethodNames(java.lang.Class<?> c)
Gets the accessible methods names known for a given class.
|
java.lang.reflect.Method[] |
getMethods(java.lang.Class<?> c,
java.lang.String methodName)
Gets all the methods with a given name from this map.
|
AbstractExecutor.Set |
getSetExecutor(java.lang.Object obj,
java.lang.Object identifier,
java.lang.Object arg)
Return a property setter.
|
void |
setClassLoader(java.lang.ClassLoader loader)
Sets the underlying class loader for class solving resolution.
|
protected java.lang.Integer |
toInteger(java.lang.Object arg)
Coerce an Object to an Integer.
|
protected java.lang.String |
toString(java.lang.Object arg)
Coerce an Object to a String.
|
protected final org.apache.commons.logging.Log rlog
private volatile java.lang.ref.SoftReference<IntrospectorBase> ref
protected Introspector(org.apache.commons.logging.Log log)
log
- the logger to use for warnings.protected java.lang.Integer toInteger(java.lang.Object arg)
arg
- the Object to coerceprotected java.lang.String toString(java.lang.Object arg)
arg
- the Object to coerceprotected final IntrospectorBase base()
If the reference has been collected, this method will recreate the underlying introspector.
public void setClassLoader(java.lang.ClassLoader loader)
loader
- the loader to usepublic java.lang.Class<?> getClassByName(java.lang.String className)
className
- the class namepublic final java.lang.reflect.Field getField(java.lang.Class<?> c, java.lang.String key)
key
for the class c
.c
- Class in which the field search is taking placekey
- Name of the field being searched forField
or null if it does not exist or is not accessiblepublic final java.lang.String[] getFieldNames(java.lang.Class<?> c)
c
- the classpublic final java.lang.reflect.Method getMethod(java.lang.Class<?> c, java.lang.String name, java.lang.Object[] params)
name
and
params
for the Class c
.c
- Class in which the method search is taking placename
- Name of the method being searched forparams
- An array of Objects (not Classes) that describe the
the parametersMethod
or null if no unambiguous method could be found through introspection.public final java.lang.reflect.Method getMethod(java.lang.Class<?> c, MethodKey key)
key
and for the Class c
.c
- Class in which the method search is taking placekey
- MethodKey of the method being searched forMethod
or null if no unambiguous method could be found through introspection.public final java.lang.String[] getMethodNames(java.lang.Class<?> c)
c
- the classpublic final java.lang.reflect.Method[] getMethods(java.lang.Class<?> c, java.lang.String methodName)
c
- the classmethodName
- the seeked methods namepublic final java.lang.reflect.Constructor<?> getConstructor(java.lang.Object ctorHandle, java.lang.Object[] args)
ctorHandle
- the objectargs
- contructor argumentsConstructor
or null if no unambiguous contructor could be found through introspection.public final AbstractExecutor.Method getMethodExecutor(java.lang.Object obj, java.lang.String name, java.lang.Object[] args)
obj
- the objectname
- the method nameargs
- method argumentsAbstractExecutor.Method
.public final AbstractExecutor.Get getGetExecutor(java.lang.Object obj, java.lang.Object identifier)
obj
- the object to base the property from.identifier
- property nameAbstractExecutor.Get
.public final AbstractExecutor.Set getSetExecutor(java.lang.Object obj, java.lang.Object identifier, java.lang.Object arg)
obj
- the object to base the property from.identifier
- property name (or identifier)arg
- value to setAbstractExecutor.Set
.