java.lang.Object
org.apache.commons.jexl3.internal.introspection.Uberspect
All Implemented Interfaces:
JexlUberspect

public class Uberspect extends Object implements JexlUberspect
Implements Uberspect to provide the default introspective functionality of JEXL.

This is the class to derive to customize introspection.

Since:
1.0
  • Field Details

    • TRY_FAILED

      public static final Object TRY_FAILED
      Publicly exposed special failure object returned by tryInvoke.
    • logger

      protected final org.apache.commons.logging.Log logger
      The logger to use for all warnings and errors.
    • strategy

      private final JexlUberspect.ResolverStrategy strategy
      The resolver strategy.
    • permissions

      private final JexlPermissions permissions
      The permissions.
    • version

      private final AtomicInteger version
      The introspector version.
    • ref

      private volatile Reference<Introspector> ref
      The soft reference to the introspector currently in use.
    • loader

      private volatile Reference<ClassLoader> loader
      The class loader reference; used to recreate the introspector when necessary.
    • operatorMap

      private final Map<Class<? extends JexlArithmetic>,Set<JexlOperator>> 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

      public Uberspect(org.apache.commons.logging.Log runtimeLogger, JexlUberspect.ResolverStrategy sty)
      Creates a new Uberspect.
      Parameters:
      runtimeLogger - the logger used for all logging needs
      sty - 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 needs
      sty - the resolver strategy
      perms - the introspector permissions
  • Method Details

    • base

      protected final Introspector base()
      Gets the current introspector base.

      If the reference has been collected, this method will recreate the underlying introspector.

      Returns:
      the introspector
    • getArithmetic

      public JexlArithmetic.Uberspect getArithmetic(JexlArithmetic arithmetic)
      Description copied from interface: JexlUberspect
      Gets an arithmetic operator resolver for a given arithmetic instance.
      Specified by:
      getArithmetic in interface JexlUberspect
      Parameters:
      arithmetic - the arithmetic instance
      Returns:
      the arithmetic uberspect or null if no operator method were overridden
    • getClassByName

      public final Class<?> getClassByName(String className)
      Gets a class by name through this introspector class loader.
      Specified by:
      getClassByName in interface JexlUberspect
      Parameters:
      className - the class name
      Returns:
      the class instance or null if it could not be found
    • getClassLoader

      public ClassLoader getClassLoader()
      Description copied from interface: JexlUberspect
      Gets the current class loader.
      Specified by:
      getClassLoader in interface JexlUberspect
      Returns:
      the class loader
    • getConstructor

      public JexlMethod getConstructor(Object ctorHandle, Object... args)
      Description copied from interface: JexlUberspect
      Returns a class constructor.
      Specified by:
      getConstructor in interface JexlUberspect
      Parameters:
      ctorHandle - a class or class name
      args - constructor arguments
      Returns:
      a JexlMethod
    • getField

      public final Field getField(Class<?> c, String key)
      Gets the field named by key for the class c.
      Parameters:
      c - Class in which the field search is taking place
      key - Name of the field being searched for
      Returns:
      a Field or null if it does not exist or is not accessible
    • getFieldNames

      public final String[] getFieldNames(Class<?> c)
      Gets the accessible field names known for a given class.
      Parameters:
      c - the class
      Returns:
      the class field names
    • getIterator

      public Iterator<?> getIterator(Object obj)
      Description copied from interface: JexlUberspect
      Gets an iterator from an object.
      Specified by:
      getIterator in interface JexlUberspect
      Parameters:
      obj - to get the iterator from
      Returns:
      an iterator over obj or null
    • getMethod

      public final Method getMethod(Class<?> c, MethodKey key)
      Gets the method defined by key and for the Class c.
      Parameters:
      c - Class in which the method search is taking place
      key - MethodKey of the method being searched for
      Returns:
      a Method or null if no unambiguous method could be found through introspection.
    • getMethod

      public final Method getMethod(Class<?> c, String name, Object[] params)
      Gets the method defined by name and params for the Class c.
      Parameters:
      c - Class in which the method search is taking place
      name - Name of the method being searched for
      params - 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

      public JexlMethod getMethod(Object obj, String method, Object... args)
      Description copied from interface: JexlUberspect
      Returns a JexlMethod.
      Specified by:
      getMethod in interface JexlUberspect
      Parameters:
      obj - the object
      method - the method name
      args - method arguments
      Returns:
      a JexlMethod
    • getMethodNames

      public final String[] getMethodNames(Class<?> c)
      Gets the accessible methods names known for a given class.
      Parameters:
      c - the class
      Returns:
      the class method names
    • getMethods

      public final Method[] getMethods(Class<?> c, String methodName)
      Gets all the methods with a given name from this map.
      Parameters:
      c - the class
      methodName - 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 bar.woogie.

      See JexlUberspect.ResolverStrategy.apply(JexlOperator, java.lang.Object)
      Specified by:
      getPropertyGet in interface JexlUberspect
      Parameters:
      resolvers - the list of property resolvers to try
      obj - the object to get the property from
      identifier - property name
      Returns:
      a JexlPropertyGet or null
    • getPropertyGet

      public JexlPropertyGet getPropertyGet(Object obj, Object identifier)
      Description copied from interface: JexlUberspect
      Property getter.

      returns a JelPropertySet apropos to an expression like bar.woogie.

      Specified by:
      getPropertyGet in interface JexlUberspect
      Parameters:
      obj - the object to get the property from
      identifier - 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 foo.bar = "geir".

      See JexlUberspect.ResolverStrategy.apply(JexlOperator, java.lang.Object)
      Specified by:
      getPropertySet in interface JexlUberspect
      Parameters:
      resolvers - the list of property resolvers to try,
      obj - the object to get the property from
      identifier - property name
      arg - value to set
      Returns:
      a JexlPropertySet or null
    • getPropertySet

      public JexlPropertySet getPropertySet(Object obj, Object identifier, Object arg)
      Description copied from interface: JexlUberspect
      Property setter.

      Seeks a JelPropertySet apropos to an expression like foo.bar = "geir".

      Specified by:
      getPropertySet in interface JexlUberspect
      Parameters:
      obj - the object to get the property from.
      identifier - property name
      arg - value to set
      Returns:
      a JexlPropertySet or null
    • getResolvers

      public List<JexlUberspect.PropertyResolver> getResolvers(JexlOperator op, Object obj)
      Description copied from interface: JexlUberspect
      Applies this uberspect property resolver strategy.
      Specified by:
      getResolvers in interface JexlUberspect
      Parameters:
      op - the operator
      obj - 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 interface JexlUberspect
      Returns:
      the class loader modification count
    • setClassLoader

      public void setClassLoader(ClassLoader nloader)
      Description copied from interface: JexlUberspect
      Sets the class loader to use.

      This increments the version.

      Specified by:
      setClassLoader in interface JexlUberspect
      Parameters:
      nloader - the class loader