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 classThe 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.LogThe 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 JexlPermissionsThe permissions.private Reference<Introspector> The soft reference to the introspector currently in use.private final JexlUberspect.ResolverStrategyThe resolver strategy.static final ObjectPublicly exposed special failure object returned by tryInvoke.private final AtomicIntegerThe 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 Introspectorbase()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 FieldGets the field named bykeyfor 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 MethodGets the method defined bynameandparamsfor the Classc.final MethodGets the method defined bykeyand 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.intGets this uberspect version.voidsetClassLoader(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:JexlUberspectGets an arithmetic operator resolver for a given arithmetic instance.- Specified by:
getArithmeticin 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:
getClassByNamein interfaceJexlUberspect- Parameters:
className- the class name- Returns:
- the class instance or null if it could not be found
-
getClassLoader
Description copied from interface:JexlUberspectGets the current class loader.- Specified by:
getClassLoaderin interfaceJexlUberspect- Returns:
- the class loader
-
getConstructor
Description copied from interface:JexlUberspectReturns a class constructor.- Specified by:
getConstructorin interfaceJexlUberspect- Parameters:
ctorHandle- a class or class nameargs- constructor arguments- Returns:
- a
JexlMethod
-
getField
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
Gets the accessible field names known for a given class.- Parameters:
c- the class- Returns:
- the class field names
-
getIterator
Description copied from interface:JexlUberspectGets an iterator from an object.- Specified by:
getIteratorin interfaceJexlUberspect- Parameters:
obj- to get the iterator from- Returns:
- an iterator over obj or null
-
getMethod
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.
-
getMethod
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 parameters- Returns:
- a
Methodor null if no unambiguous method could be found through introspection.
-
getMethod
Description copied from interface:JexlUberspectReturns a JexlMethod.- Specified by:
getMethodin 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:JexlUberspectProperty getter.Seeks a JexlPropertyGet apropos to an expression like
Seebar.woogie.JexlUberspect.ResolverStrategy.apply(JexlOperator, java.lang.Object)- Specified by:
getPropertyGetin interfaceJexlUberspect- Parameters:
resolvers- the list of property resolvers to tryobj- the object to get the property fromidentifier- property name- Returns:
- a
JexlPropertyGetor null
-
getPropertyGet
Description copied from interface:JexlUberspectProperty getter.returns a JelPropertySet apropos to an expression like
bar.woogie.- Specified by:
getPropertyGetin interfaceJexlUberspect- Parameters:
obj- the object to get the property fromidentifier- property name- Returns:
- a
JexlPropertyGetor null
-
getPropertySet
public JexlPropertySet getPropertySet(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier, Object arg) Description copied from interface:JexlUberspectProperty setter.Seeks a JelPropertySet apropos to an expression like
Seefoo.bar = "geir".JexlUberspect.ResolverStrategy.apply(JexlOperator, java.lang.Object)- Specified by:
getPropertySetin 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
JexlPropertySetor null
-
getPropertySet
Description copied from interface:JexlUberspectProperty setter.Seeks a JelPropertySet apropos to an expression like
foo.bar = "geir".- Specified by:
getPropertySetin interfaceJexlUberspect- Parameters:
obj- the object to get the property from.identifier- property namearg- value to set- Returns:
- a
JexlPropertySetor null
-
getResolvers
Description copied from interface:JexlUberspectApplies this uberspect property resolver strategy.- Specified by:
getResolversin interfaceJexlUberspect- Parameters:
op- the operatorobj- the object- Returns:
- the applied strategy resolver list
-
getVersion
public int getVersion()Description copied from interface:JexlUberspectGets this uberspect version.- Specified by:
getVersionin interfaceJexlUberspect- Returns:
- the class loader modification count
-
setClassLoader
Description copied from interface:JexlUberspectSets the class loader to use.This increments the version.
- Specified by:
setClassLoaderin interfaceJexlUberspect- Parameters:
nloader- the class loader
-