Class Introspector
- java.lang.Object
-
- org.apache.commons.jexl2.internal.Introspector
-
- Direct Known Subclasses:
UberspectImpl
public class Introspector extends java.lang.Object
Default introspection services.Finding methods as well as property getters & setters.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.LogrlogThe logger to use for all warnings & errors.
-
Constructor Summary
Constructors Modifier Constructor Description protectedIntrospector(org.apache.commons.logging.Log log)Creates an introspector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IntrospectorBasebase()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.FieldgetField(java.lang.Class<?> c, java.lang.String key)Gets the field named bykeyfor the classc.java.lang.String[]getFieldNames(java.lang.Class<?> c)Gets the accessible field names known for a given class.AbstractExecutor.GetgetGetExecutor(java.lang.Object obj, java.lang.Object identifier)Return a property getter.java.lang.reflect.MethodgetMethod(java.lang.Class<?> c, java.lang.String name, java.lang.Object[] params)Gets the method defined bynameandparamsfor the Classc.java.lang.reflect.MethodgetMethod(java.lang.Class<?> c, MethodKey key)Gets the method defined bykeyand for the Classc.AbstractExecutor.MethodgetMethodExecutor(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.SetgetSetExecutor(java.lang.Object obj, java.lang.Object identifier, java.lang.Object arg)Return a property setter.voidsetClassLoader(java.lang.ClassLoader loader)Sets the underlying class loader for class solving resolution.protected java.lang.IntegertoInteger(java.lang.Object arg)Coerce an Object to an Integer.protected java.lang.StringtoString(java.lang.Object arg)Coerce an Object to a String.
-
-
-
Field Detail
-
rlog
protected final org.apache.commons.logging.Log rlog
The logger to use for all warnings & errors.
-
-
Constructor Detail
-
Introspector
protected Introspector(org.apache.commons.logging.Log log)
Creates an introspector.- Parameters:
log- the logger to use for warnings.
-
-
Method Detail
-
toInteger
protected java.lang.Integer toInteger(java.lang.Object arg)
Coerce an Object to an Integer.- Parameters:
arg- the Object to coerce- Returns:
- an Integer if it can be converted, null otherwise
-
toString
protected java.lang.String toString(java.lang.Object arg)
Coerce an Object to a String.- Parameters:
arg- the Object to coerce- Returns:
- a String if it can be converted, null otherwise
-
base
protected final IntrospectorBase base()
Gets the current introspector base.If the reference has been collected, this method will recreate the underlying introspector.
- Returns:
- the introspector
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader loader)
Sets the underlying class loader for class solving resolution.- Parameters:
loader- the loader to use
-
getClassByName
public java.lang.Class<?> getClassByName(java.lang.String className)
Gets a class by name through this introspector class loader.- Parameters:
className- the class name- Returns:
- the class instance or null if it could not be found
-
getField
public final java.lang.reflect.Field getField(java.lang.Class<?> c, java.lang.String key)
Gets the field named bykeyfor the classc.- Parameters:
c- Class in which the field search is taking placekey- Name of the field being searched for- Returns:
- a
Fieldor null if it does not exist or is not accessible
-
getFieldNames
public final java.lang.String[] getFieldNames(java.lang.Class<?> c)
Gets the accessible field names known for a given class.- Parameters:
c- the class- Returns:
- the class field names
-
getMethod
public final java.lang.reflect.Method getMethod(java.lang.Class<?> c, java.lang.String name, java.lang.Object[] params)
Gets the method defined bynameandparamsfor the Classc.- Parameters:
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 parameters- Returns:
- a
Methodor null if no unambiguous method could be found through introspection.
-
getMethod
public final java.lang.reflect.Method getMethod(java.lang.Class<?> c, MethodKey key)
Gets the method defined bykeyand for the Classc.- Parameters:
c- Class in which the method search is taking placekey- MethodKey of the method being searched for- Returns:
- a
Methodor null if no unambiguous method could be found through introspection.
-
getMethodNames
public final java.lang.String[] getMethodNames(java.lang.Class<?> c)
Gets the accessible methods names known for a given class.- Parameters:
c- the class- Returns:
- the class method names
-
getMethods
public final java.lang.reflect.Method[] getMethods(java.lang.Class<?> c, java.lang.String methodName)
Gets all the methods with a given name from this map.- Parameters:
c- the classmethodName- the seeked methods name- Returns:
- the array of methods
-
getConstructor
public final java.lang.reflect.Constructor<?> getConstructor(java.lang.Object ctorHandle, java.lang.Object[] args)
Returns a general constructor.- Parameters:
ctorHandle- the objectargs- contructor arguments- Returns:
- a
Constructoror null if no unambiguous contructor could be found through introspection.
-
getMethodExecutor
public final AbstractExecutor.Method getMethodExecutor(java.lang.Object obj, java.lang.String name, java.lang.Object[] args)
Returns a general method.- Parameters:
obj- the objectname- the method nameargs- method arguments- Returns:
- a
AbstractExecutor.Method.
-
getGetExecutor
public final AbstractExecutor.Get getGetExecutor(java.lang.Object obj, java.lang.Object identifier)
Return a property getter.- Parameters:
obj- the object to base the property from.identifier- property name- Returns:
- a
AbstractExecutor.Get.
-
getSetExecutor
public final AbstractExecutor.Set getSetExecutor(java.lang.Object obj, java.lang.Object identifier, java.lang.Object arg)
Return a property setter.- Parameters:
obj- the object to base the property from.identifier- property name (or identifier)arg- value to set- Returns:
- a
AbstractExecutor.Set.
-
-