org.apache.commons.jexl3.internal.introspection
Class Uberspect

java.lang.Object
  extended by org.apache.commons.jexl3.internal.Introspector
      extended by org.apache.commons.jexl3.internal.introspection.Uberspect
All Implemented Interfaces:
Uberspect
Direct Known Subclasses:
SandboxUberspect

public class Uberspect
extends Introspector
implements Uberspect

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
static class Uberspect.IndexedContainer
          A generic indexed property container, exposes get(key) and set(key, value) and solves method call dynamically based on arguments.
 
Field Summary
static Object TRY_FAILED
          Publicly exposed special failure object returned by tryInvoke.
 
Fields inherited from class org.apache.commons.jexl3.internal.Introspector
rlog
 
Constructor Summary
Uberspect(org.apache.commons.logging.Log runtimeLogger)
          Creates a new UberspectImpl.
 
Method Summary
 JexlMethod getConstructor(Object ctorHandle, Object[] args, JexlInfo.Handle info)
          Returns a class constructor.
protected  Field getField(Object obj, String name, JexlInfo info)
          Returns a class field.
protected  JexlPropertyGet getIndexedGet(Object object, String name)
          Attempts to find an indexed-property getter in an object.
 Iterator<?> getIterator(Object obj, JexlInfo.Handle info)
          Gets an iterator from an object.
 JexlMethod getMethod(Object obj, String method, Object[] args, JexlInfo.Handle info)
          Returns a JexlMethod.
 JexlPropertyGet getPropertyGet(Object obj, Object identifier, JexlInfo.Handle info)
          Property getter.
 JexlPropertySet getPropertySet(Object obj, Object identifier, Object arg, JexlInfo.Handle info)
          Property setter.
 void setLoader(ClassLoader cloader)
          Resets this Uberspect class loader.
 
Methods inherited from class org.apache.commons.jexl3.internal.Introspector
base, getClassByName, getConstructor, getField, getFieldNames, getGetExecutor, getMethod, getMethod, getMethodExecutor, getMethodNames, getMethods, getSetExecutor, setClassLoader, toInteger, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jexl3.introspection.Uberspect
setClassLoader
 

Field Detail

TRY_FAILED

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

Constructor Detail

Uberspect

public Uberspect(org.apache.commons.logging.Log runtimeLogger)
Creates a new UberspectImpl.

Parameters:
runtimeLogger - the logger used for all logging needs
Method Detail

setLoader

public void setLoader(ClassLoader cloader)
Resets this Uberspect class loader.

Parameters:
cloader - the class loader to use

getIterator

public Iterator<?> getIterator(Object obj,
                               JexlInfo.Handle info)
Gets an iterator from an object.

Specified by:
getIterator in interface Uberspect
Parameters:
obj - to get the iterator for
info - contextual information
Returns:
an iterator over obj

getMethod

public JexlMethod getMethod(Object obj,
                            String method,
                            Object[] args,
                            JexlInfo.Handle info)
Returns a JexlMethod.

Specified by:
getMethod in interface Uberspect
Parameters:
obj - the object
method - the method name
args - method arguments
info - contextual information
Returns:
a JexlMethod

getConstructor

public JexlMethod getConstructor(Object ctorHandle,
                                 Object[] args,
                                 JexlInfo.Handle info)
Returns a class constructor.

Specified by:
getConstructor in interface Uberspect
Parameters:
ctorHandle - a class or class name
args - constructor arguments
info - contextual information
Returns:
a JexlMethod

getPropertyGet

public JexlPropertyGet getPropertyGet(Object obj,
                                      Object identifier,
                                      JexlInfo.Handle info)
Property getter.

Returns JexlPropertyGet appropos for ${bar.woogie}.

Specified by:
getPropertyGet in interface Uberspect
Parameters:
obj - the object to get the property from
identifier - property name
info - contextual information
Returns:
a JexlPropertyGet

getPropertySet

public JexlPropertySet getPropertySet(Object obj,
                                      Object identifier,
                                      Object arg,
                                      JexlInfo.Handle info)
Property setter.

returns JelPropertySet appropos for ${foo.bar = "geir"}

.

Specified by:
getPropertySet in interface Uberspect
Parameters:
obj - the object to get the property from.
identifier - property name
arg - value to set
info - contextual information
Returns:
a JexlPropertySet.

getField

protected Field getField(Object obj,
                         String name,
                         JexlInfo info)
Returns a class field.

Parameters:
obj - the object
name - the field name
info - debug info
Returns:
a Field.

getIndexedGet

protected JexlPropertyGet getIndexedGet(Object object,
                                        String name)
Attempts to find an indexed-property getter in an object. The code attempts to find the list of methods getXXX() and setXXX(). Note that this is not equivalent to the strict bean definition of indexed properties; the type of the key is not necessarily an int and the set/get arrays are not resolved.

Parameters:
object - the object
name - the container name
Returns:
a JexlPropertyGet is successfull, null otherwise


Copyright © 2001-2011 The Apache Software Foundation. All Rights Reserved.