Class Uberspect
java.lang.Object
org.apache.commons.jexl3.internal.introspection.Uberspect
- All Implemented Interfaces:
JexlUberspect
Implements Uberspect to provide the default introspective
functionality of JEXL.
This is the class to derive to customize introspection.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
The concrete uberspect Arithmetic class.Nested classes/interfaces inherited from interface org.apache.commons.jexl3.introspection.JexlUberspect
JexlUberspect.JexlResolver, JexlUberspect.PropertyResolver, JexlUberspect.ResolverStrategy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Reference
<ClassLoader> The class loader reference; used to recreate the introspector when necessary.protected final org.apache.commons.logging.Log
The logger to use for all warnings and errors.private final Map
<Class<? extends JexlArithmetic>, Set<JexlOperator>> The map from arithmetic classes to overloaded operator sets.private final JexlPermissions
The permissions.private Reference
<Introspector> The soft reference to the introspector currently in use.private final JexlUberspect.ResolverStrategy
The resolver strategy.static final Object
Publicly exposed special failure object returned by tryInvoke.private final AtomicInteger
The introspector version.Fields inherited from interface org.apache.commons.jexl3.introspection.JexlUberspect
JEXL_STRATEGY, MAP, MAP_STRATEGY, POJO
-
Constructor Summary
ConstructorsConstructorDescriptionUberspect
(org.apache.commons.logging.Log runtimeLogger, JexlUberspect.ResolverStrategy sty) Creates a new Uberspect.Uberspect
(org.apache.commons.logging.Log runtimeLogger, JexlUberspect.ResolverStrategy sty, JexlPermissions perms) Creates a new Uberspect. -
Method Summary
Modifier and TypeMethodDescriptionprotected final Introspector
base()
Gets the current introspector base.getArithmetic
(JexlArithmetic arithmetic) Gets an arithmetic operator resolver for a given arithmetic instance.final Class
<?> getClassByName
(String className) Gets a class by name through this introspector class loader.Gets the current class loader.getConstructor
(Object ctorHandle, Object... args) Returns a class constructor.final Field
Gets the field named bykey
for the classc
.final String[]
getFieldNames
(Class<?> c) Gets the accessible field names known for a given class.Iterator
<?> getIterator
(Object obj) Gets an iterator from an object.final Method
Gets the method defined byname
andparams
for the Classc
.final Method
Gets the method defined bykey
and for the Classc
.Returns a JexlMethod.final String[]
getMethodNames
(Class<?> c) Gets the accessible methods names known for a given class.final Method[]
getMethods
(Class<?> c, String methodName) Gets all the methods with a given name from this map.getPropertyGet
(Object obj, Object identifier) Property getter.getPropertyGet
(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier) Property getter.getPropertySet
(Object obj, Object identifier, Object arg) Property setter.getPropertySet
(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier, Object arg) Property setter.getResolvers
(JexlOperator op, Object obj) Applies this uberspect property resolver strategy.int
Gets this uberspect version.void
setClassLoader
(ClassLoader nloader) Sets the class loader to use.
-
Field Details
-
TRY_FAILED
Publicly exposed special failure object returned by tryInvoke. -
logger
protected final org.apache.commons.logging.Log loggerThe logger to use for all warnings and errors. -
strategy
The resolver strategy. -
permissions
The permissions. -
version
The introspector version. -
ref
The soft reference to the introspector currently in use. -
loader
The class loader reference; used to recreate the introspector when necessary. -
operatorMap
The map from arithmetic classes to overloaded operator sets.This map keeps track of which operator methods are overloaded per JexlArithmetic classes allowing a fail fast test during interpretation by avoiding seeking a method when there is none.
-
-
Constructor Details
-
Uberspect
Creates a new Uberspect.- Parameters:
runtimeLogger
- the logger used for all logging needssty
- the resolver strategy
-
Uberspect
public Uberspect(org.apache.commons.logging.Log runtimeLogger, JexlUberspect.ResolverStrategy sty, JexlPermissions perms) Creates a new Uberspect.- Parameters:
runtimeLogger
- the logger used for all logging needssty
- the resolver strategyperms
- the introspector permissions
-
-
Method Details
-
base
Gets the current introspector base.If the reference has been collected, this method will recreate the underlying introspector.
- Returns:
- the introspector
-
getArithmetic
Description copied from interface:JexlUberspect
Gets an arithmetic operator resolver for a given arithmetic instance.- Specified by:
getArithmetic
in interfaceJexlUberspect
- Parameters:
arithmetic
- the arithmetic instance- Returns:
- the arithmetic uberspect or null if no operator method were overridden
-
getClassByName
Gets a class by name through this introspector class loader.- Specified by:
getClassByName
in interfaceJexlUberspect
- Parameters:
className
- the class name- Returns:
- the class instance or null if it could not be found
-
getClassLoader
Description copied from interface:JexlUberspect
Gets the current class loader.- Specified by:
getClassLoader
in interfaceJexlUberspect
- Returns:
- the class loader
-
getConstructor
Description copied from interface:JexlUberspect
Returns a class constructor.- Specified by:
getConstructor
in interfaceJexlUberspect
- Parameters:
ctorHandle
- a class or class nameargs
- constructor arguments- Returns:
- a
JexlMethod
-
getField
Gets the field named bykey
for the classc
.- Parameters:
c
- Class in which the field search is taking placekey
- Name of the field being searched for- Returns:
- a
Field
or null if it does not exist or is not accessible
-
getFieldNames
Gets the accessible field names known for a given class.- Parameters:
c
- the class- Returns:
- the class field names
-
getIterator
Description copied from interface:JexlUberspect
Gets an iterator from an object.- Specified by:
getIterator
in interfaceJexlUberspect
- Parameters:
obj
- to get the iterator from- Returns:
- an iterator over obj or null
-
getMethod
Gets the method defined bykey
and for the Classc
.- Parameters:
c
- Class in which the method search is taking placekey
- MethodKey of the method being searched for- Returns:
- a
Method
or null if no unambiguous method could be found through introspection.
-
getMethod
Gets the method defined byname
andparams
for 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 parameters- Returns:
- a
Method
or null if no unambiguous method could be found through introspection.
-
getMethod
Description copied from interface:JexlUberspect
Returns a JexlMethod.- Specified by:
getMethod
in interfaceJexlUberspect
- Parameters:
obj
- the objectmethod
- the method nameargs
- method arguments- Returns:
- a
JexlMethod
-
getMethodNames
Gets the accessible methods names known for a given class.- Parameters:
c
- the class- Returns:
- the class method names
-
getMethods
Gets all the methods with a given name from this map.- Parameters:
c
- the classmethodName
- the seeked methods name- Returns:
- the array of methods
-
getPropertyGet
public JexlPropertyGet getPropertyGet(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier) Description copied from interface:JexlUberspect
Property getter.Seeks a JexlPropertyGet apropos to an expression like
Seebar.woogie
.JexlUberspect.ResolverStrategy.apply(JexlOperator, java.lang.Object)
- Specified by:
getPropertyGet
in interfaceJexlUberspect
- Parameters:
resolvers
- the list of property resolvers to tryobj
- the object to get the property fromidentifier
- property name- Returns:
- a
JexlPropertyGet
or null
-
getPropertyGet
Description copied from interface:JexlUberspect
Property getter.returns a JelPropertySet apropos to an expression like
bar.woogie
.- Specified by:
getPropertyGet
in interfaceJexlUberspect
- Parameters:
obj
- the object to get the property fromidentifier
- property name- Returns:
- a
JexlPropertyGet
or null
-
getPropertySet
public JexlPropertySet getPropertySet(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier, Object arg) Description copied from interface:JexlUberspect
Property setter.Seeks a JelPropertySet apropos to an expression like
Seefoo.bar = "geir"
.JexlUberspect.ResolverStrategy.apply(JexlOperator, java.lang.Object)
- Specified by:
getPropertySet
in interfaceJexlUberspect
- Parameters:
resolvers
- the list of property resolvers to try,obj
- the object to get the property fromidentifier
- property namearg
- value to set- Returns:
- a
JexlPropertySet
or null
-
getPropertySet
Description copied from interface:JexlUberspect
Property setter.Seeks a JelPropertySet apropos to an expression like
foo.bar = "geir"
.- Specified by:
getPropertySet
in interfaceJexlUberspect
- Parameters:
obj
- the object to get the property from.identifier
- property namearg
- value to set- Returns:
- a
JexlPropertySet
or null
-
getResolvers
Description copied from interface:JexlUberspect
Applies this uberspect property resolver strategy.- Specified by:
getResolvers
in interfaceJexlUberspect
- Parameters:
op
- the operatorobj
- the object- Returns:
- the applied strategy resolver list
-
getVersion
public int getVersion()Description copied from interface:JexlUberspect
Gets this uberspect version.- Specified by:
getVersion
in interfaceJexlUberspect
- Returns:
- the class loader modification count
-
setClassLoader
Description copied from interface:JexlUberspect
Sets the class loader to use.This increments the version.
- Specified by:
setClassLoader
in interfaceJexlUberspect
- Parameters:
nloader
- the class loader
-