org.apache.commons.jexl3.internal.introspection

## Class Uberspect

- java.lang.Object
- - org.apache.commons.jexl3.internal.introspection.Uberspect

- All Implemented Interfaces:
    JexlUberspect

      public class Uberspect
      extends Object
      implements JexlUberspect

  Implementation of 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 Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `Uberspect.ArithmeticUberspect` 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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.commons.logging.Log` | `rlog` The logger to use for all warnings and errors.
    `static Object` | `TRY_FAILED` Publicly exposed special failure object returned by tryInvoke.

    - ### Fields inherited from interface org.apache.commons.jexl3.introspection.JexlUberspect

      `JEXL_STRATEGY, MAP, MAP_STRATEGY, POJO`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Uberspect(org.apache.commons.logging.Log runtimeLogger, JexlUberspect.ResolverStrategy sty)` Creates a new Uberspect.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Introspector` | `base()` Gets the current introspector base.
    `JexlArithmetic.Uberspect` | `getArithmetic(JexlArithmetic arithmetic)` Gets an arithmetic operator resolver for a given arithmetic instance.
    `Class<?>` | `getClassByName(String className)` Gets a class by name through this introspector class loader.
    `JexlMethod` | `getConstructor(Object ctorHandle, Object... args)` Returns a class constructor.
    `Field` | `getField(Class<?> c, String key)` Gets the field named by `key` for the class `c`.
    `String[]` | `getFieldNames(Class<?> c)` Gets the accessible field names known for a given class.
    `Iterator<?>` | `getIterator(Object obj)` Gets an iterator from an object.
    `Method` | `getMethod(Class<?> c, MethodKey key)` Gets the method defined by `key` and for the Class `c`.
    `Method` | `getMethod(Class<?> c, String name, Object[] params)` Gets the method defined by `name` and `params` for the Class `c`.
    `JexlMethod` | `getMethod(Object obj, String method, Object... args)` Returns a JexlMethod.
    `String[]` | `getMethodNames(Class<?> c)` Gets the accessible methods names known for a given class.
    `Method[]` | `getMethods(Class<?> c, String methodName)` Gets all the methods with a given name from this map.
    `JexlPropertyGet` | `getPropertyGet(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier)` Property getter.
    `JexlPropertyGet` | `getPropertyGet(Object obj, Object identifier)` Property getter.
    `JexlPropertySet` | `getPropertySet(List<JexlUberspect.PropertyResolver> resolvers, Object obj, Object identifier, Object arg)` Property setter.
    `JexlPropertySet` | `getPropertySet(Object obj, Object identifier, Object arg)` Property setter.
    `List<JexlUberspect.PropertyResolver>` | `getResolvers(JexlOperator op, Object obj)` Applies this uberspect property resolver strategy.
    `int` | `getVersion()` Gets this uberspect version.
    `void` | `setClassLoader(ClassLoader nloader)` Sets the class loader to use.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TRY_FAILED

          public static final Object TRY_FAILED

      Publicly exposed special failure object returned by tryInvoke.

    - #### rlog

          protected final org.apache.commons.logging.Log rlog

      The logger to use for all warnings and errors.

  - ### Constructor Detail

    - #### 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

  - ### Method Detail

    - #### 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

    - #### setClassLoader

          public void setClassLoader(ClassLoader nloader)

      Sets the class loader to use.

      This increments the version.

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

    - #### getVersion

          public int getVersion()

      Gets this uberspect version.
      Specified by:
        `getVersion` in interface `JexlUberspect`
      Returns:
        the class loader modification count

    - #### getClassByName

          public final Class<?> getClassByName(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 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

    - #### 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 the parameters
      Returns:
        a `Method` or null if no unambiguous method could be found through introspection.

    - #### 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.

    - #### 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

    - #### getMethod

          public JexlMethod getMethod(Object obj,
                             String method,
                             Object... args)

      Returns a JexlMethod.
      Specified by:
        `getMethod` in interface `JexlUberspect`
      Parameters:
        `obj` - the object
        `method` - the method name
        `args` - method arguments
      Returns:
        a `JexlMethod`

    - #### getResolvers

          public List<JexlUberspect.PropertyResolver> getResolvers(JexlOperator op,
                                                          Object obj)

      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

    - #### getPropertyGet

          public JexlPropertyGet getPropertyGet(Object obj,
                                       Object identifier)

      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

    - #### getPropertyGet

          public JexlPropertyGet getPropertyGet(List<JexlUberspect.PropertyResolver> resolvers,
                                       Object obj,
                                       Object identifier)

      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

    - #### getPropertySet

          public JexlPropertySet getPropertySet(Object obj,
                                       Object identifier,
                                       Object arg)

      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

    - #### getPropertySet

          public JexlPropertySet getPropertySet(List<JexlUberspect.PropertyResolver> resolvers,
                                       Object obj,
                                       Object identifier,
                                       Object arg)

      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

    - #### getIterator

          public Iterator<?> getIterator(Object obj)

      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

    - #### getConstructor

          public JexlMethod getConstructor(Object ctorHandle,
                                  Object... args)

      Returns a class constructor.
      Specified by:
        `getConstructor` in interface `JexlUberspect`
      Parameters:
        `ctorHandle` - a class or class name
        `args` - constructor arguments
      Returns:
        a `JexlMethod`

    - #### getArithmetic

          public JexlArithmetic.Uberspect getArithmetic(JexlArithmetic arithmetic)

      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

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.