ariba.util.expr
Class ExprRuntime

java.lang.Object
  extended by ariba.util.expr.ExprRuntime

public abstract class ExprRuntime
extends Object

This is an abstract class with static methods that define runtime caching information in AribaExpr.

Author:
Luke Blanshard (blanshlu@netscape.net), Drew Davidson (drew@ognl.org)

Field Summary
static int INDEXED_PROPERTY_INT
          JavaBeans IndexedProperty
static int INDEXED_PROPERTY_NONE
          Not an indexed property
static int INDEXED_PROPERTY_OBJECT
          AribaExpr ObjectIndexedProperty
static Object[] NoArguments
           
static Class[] NoArgumentTypes
           
static Object NoConversionPossible
          Token returned by TypeConverter for no conversion possible
static Object NotFound
           
static List NotFoundList
           
static Map NotFoundMap
           
static String NULL_DISPLY_STRING
           
static String NULL_VALUE_STRING
           
 
Constructor Summary
ExprRuntime()
           
 
Method Summary
static boolean areArgsCompatible(Object[] args, Class[] classes)
          Tells whether the given array of objects is compatible with the given array of classes---that is, whether the given array of objects can be passed as arguments to a method or constructor whose parameter types are the given array of classes.
static Object callAppropriateMethod(ExprContext context, Object source, Object target, String methodName, String propertyName, List methods, Object[] args)
           
static Object callConstructor(ExprContext context, String className, Object[] args)
           
static Object callMethod(ExprContext context, Object target, String methodName, String propertyName, Object[] args)
           
static Object callStaticMethod(ExprContext context, String className, String methodName, Object[] args)
           
static boolean canArgsWideningTo(Object[] args, Class[] classes)
          Tells whether the given array of objects is compatible with the given array of classes---that is, whether the given array of objects can be passed as arguments to a method or constructor whose parameter types are the given array of classes.
static boolean canWideningTo(Object object, Class c)
          Tells whether the given object's type can be widen to the given class ---that is, whether the given object can be passed as an argument to a method or constructor with type widdening conversion.
static Class classForName(ExprContext context, String className)
           
static Object convert(Object source)
           
static Method getAppropriateMethod(ExprContext context, Object source, Object target, String methodName, String propertyName, List methods, Object[] args, Object[] actualArgs)
          Gets the appropriate method to be called for the given target, method name and arguments.
static Class getArgClass(Object arg)
          Gets the class for a method argument that is appropriate for looking up methods by reflection, by looking for the standard primitive wrapper classes and exchanging for them their underlying primitive class objects.
static String getBaseName(Object o)
          Returns the base name (the class name without the package name prepended) of the object given.
static String getClassBaseName(Class c)
          Returns the base name (the class name without the package name prepended) of the class given.
static String getClassName(Class c, boolean fullyQualified)
           
static String getClassName(Object o, boolean fullyQualified)
           
static String getClassPackageName(Class c)
          Returns the package name of the class given.
static List getConstructors(Class targetClass)
           
static Constructor getConvertedConstructorAndArgs(ExprContext context, Object target, List constructors, Object[] args, Object[] newArgs)
           
static Method getConvertedMethodAndArgs(ExprContext context, Object target, String propertyName, List methods, Object[] args, Object[] newArgs)
           
static Object getConvertedType(ExprContext context, Object target, Member member, String propertyName, Object value, Class type)
           
static boolean getConvertedTypes(ExprContext context, Object target, Member member, String propertyName, Class[] parameterTypes, Object[] args, Object[] newArgs)
           
static List getDeclaredMethods(Class targetClass, String propertyName, boolean findSets)
           
static EvaluationPool getEvaluationPool()
           
static Field getField(Class inClass, String name)
           
static Map getFields(Class targetClass)
           
static Object getFieldValue(ExprContext context, Object target, String propertyName)
           
static Object getFieldValue(ExprContext context, Object target, String propertyName, boolean checkAccessAndExistence)
           
static Method getGetMethod(ExprContext context, Class targetClass, String propertyName)
           
static Object getIndexedProperty(ExprContext context, Object source, String name, Object index)
           
static int getIndexedPropertyType(ExprContext context, Class sourceClass, String name)
          Determines the index property type, if any.
static MethodAccessor getMethodAccessor(Class cls)
           
static Map getMethods(Class targetClass, boolean staticMethods)
           
static List getMethods(Class targetClass, String name, boolean staticMethods)
           
static Object getMethodValue(ExprContext context, Object target, String propertyName)
           
static Object getMethodValue(ExprContext context, Object target, String propertyName, boolean checkAccessAndExistence)
          If the checkAccessAndExistence flag is true this method will check to see if the method exists and if it is accessible according to the context's MemberAccess.
static String getModifierString(int modifiers)
           
static NullHandler getNullHandler(Class cls)
           
static ObjectArrayPool getObjectArrayPool()
           
static String getPackageName(Object o)
          Returns the package name of the object's class.
static Class[] getParameterTypes(Constructor c)
          Returns the parameter types of the given method.
static Class[] getParameterTypes(Method m)
          Returns the parameter types of the given method.
static Permission getPermission(Method method)
          Permission will be named "invoke..".
static String getPointerString(int num)
          Returns a "pointer" string in the usual format for these things - 0x.
static String getPointerString(Object o)
          Returns a "pointer" string in the usual format for these things - 0x for the object given.
static Object getPrimitiveDefaultValue(Class forClass)
           
static PropertyDescriptor getPropertyDescriptor(Class targetClass, String propertyName)
          This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using getPropertyDescriptorsMap()).
static PropertyDescriptor getPropertyDescriptorFromArray(Class targetClass, String name)
          Gets the property descriptor with the given name for the target class given.
static Map getPropertyDescriptors(Class targetClass)
          This method returns the property descriptors for the given class as a Map
static PropertyDescriptor[] getPropertyDescriptorsArray(Class targetClass)
           
static SecurityManager getSecurityManager()
          Gets the SecurityManager that AribaExpr uses to determine permissions for invoking methods.
static Method getSetMethod(ExprContext context, Class targetClass, String propertyName)
           
static Object getStaticField(ExprContext context, String className, String fieldName)
           
static Class getTargetClass(Object o)
          Gets the "target" class of an object for looking up accessors that are registered on the target.
static String getUniqueDescriptor(Object object)
          Returns a unique descriptor string that includes the object's class' base name and a unique integer identifier.
static String getUniqueDescriptor(Object object, boolean fullyQualified)
          Returns a unique descriptor string that includes the object's class and a unique integer identifier.
static boolean hasField(ExprContext context, Object target, Class inClass, String propertyName)
           
static boolean hasGetMethod(ExprContext context, Object target, Class targetClass, String propertyName)
           
static boolean hasGetProperty(ExprContext context, Object target, Object oname)
           
static boolean hasSetMethod(ExprContext context, Object target, Class targetClass, String propertyName)
           
static boolean hasSetProperty(ExprContext context, Object target, Object oname)
           
static Object invokeMethod(Object target, Method method, Object[] argsArray)
           
static boolean isFieldAccessible(ExprContext context, Object target, Class inClass, String propertyName)
           
static boolean isFieldAccessible(ExprContext context, Object target, Field field, String propertyName)
           
static boolean isInstance(ExprContext context, Object value, String className)
           
static boolean isMethodAccessible(ExprContext context, Object target, Method method, String propertyName)
           
static boolean isMoreSpecific(Class[] classes1, Class[] classes2)
          Tells whether the first array of classes is more specific than the second.
static boolean isTypeCompatible(Object object, Class c)
          Tells whether the given object is compatible with the given class ---that is, whether the given object can be passed as an argument to a method or constructor whose parameter type is the given class.
static boolean setFieldValue(ExprContext context, Object target, String propertyName, Object value)
           
static void setIndexedProperty(ExprContext context, Object source, String name, Object index, Object value)
           
static void setMethodAccessor(Class cls, MethodAccessor accessor)
           
static boolean setMethodValue(ExprContext context, Object target, String propertyName, Object value)
           
static boolean setMethodValue(ExprContext context, Object target, String propertyName, Object value, boolean checkAccessAndExistence)
           
static void setNullHandler(Class cls, NullHandler handler)
           
static void setSecurityManager(SecurityManager value)
          Sets the SecurityManager that AribaExpr uses to determine permissions for invoking methods.
static void setStaticField(ExprContext context, String className, String fieldName, Object value)
           
static Object[] toArray(List list)
          Utility to convert a List into an Object[] array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NotFound

public static final Object NotFound

NotFoundList

public static final List NotFoundList

NotFoundMap

public static final Map NotFoundMap

NoArguments

public static final Object[] NoArguments

NoArgumentTypes

public static final Class[] NoArgumentTypes

NoConversionPossible

public static final Object NoConversionPossible
Token returned by TypeConverter for no conversion possible


INDEXED_PROPERTY_NONE

public static int INDEXED_PROPERTY_NONE
Not an indexed property


INDEXED_PROPERTY_INT

public static int INDEXED_PROPERTY_INT
JavaBeans IndexedProperty


INDEXED_PROPERTY_OBJECT

public static int INDEXED_PROPERTY_OBJECT
AribaExpr ObjectIndexedProperty


NULL_DISPLY_STRING

public static final String NULL_DISPLY_STRING

NULL_VALUE_STRING

public static final String NULL_VALUE_STRING
See Also:
Constant Field Values
Constructor Detail

ExprRuntime

public ExprRuntime()
Method Detail

getTargetClass

public static Class getTargetClass(Object o)
Gets the "target" class of an object for looking up accessors that are registered on the target. If the object is a Class object this will return the Class itself, else it will return object's getClass() result.


getBaseName

public static String getBaseName(Object o)
Returns the base name (the class name without the package name prepended) of the object given.


getClassBaseName

public static String getClassBaseName(Class c)
Returns the base name (the class name without the package name prepended) of the class given.


getClassName

public static String getClassName(Object o,
                                  boolean fullyQualified)

getClassName

public static String getClassName(Class c,
                                  boolean fullyQualified)

getPackageName

public static String getPackageName(Object o)
Returns the package name of the object's class.


getClassPackageName

public static String getClassPackageName(Class c)
Returns the package name of the class given.


getPointerString

public static String getPointerString(int num)
Returns a "pointer" string in the usual format for these things - 0x.


getPointerString

public static String getPointerString(Object o)
Returns a "pointer" string in the usual format for these things - 0x for the object given. This will always return a unique value for each object.


getUniqueDescriptor

public static String getUniqueDescriptor(Object object,
                                         boolean fullyQualified)
Returns a unique descriptor string that includes the object's class and a unique integer identifier. If fullyQualified is true then the class name will be fully qualified to include the package name, else it will be just the class' base name.


getUniqueDescriptor

public static String getUniqueDescriptor(Object object)
Returns a unique descriptor string that includes the object's class' base name and a unique integer identifier.


toArray

public static Object[] toArray(List list)
Utility to convert a List into an Object[] array. If the list is zero elements this will return a constant array; toArray() on List always returns a new object and this is wasteful for our purposes.


getParameterTypes

public static Class[] getParameterTypes(Method m)
Returns the parameter types of the given method.


getParameterTypes

public static Class[] getParameterTypes(Constructor c)
Returns the parameter types of the given method.


getSecurityManager

public static SecurityManager getSecurityManager()
Gets the SecurityManager that AribaExpr uses to determine permissions for invoking methods.

Returns:
SecurityManager for AribaExpr

setSecurityManager

public static void setSecurityManager(SecurityManager value)
Sets the SecurityManager that AribaExpr uses to determine permissions for invoking methods.

Parameters:
value - SecurityManager to set

getPermission

public static Permission getPermission(Method method)
Permission will be named "invoke..".


invokeMethod

public static Object invokeMethod(Object target,
                                  Method method,
                                  Object[] argsArray)
                           throws InvocationTargetException,
                                  IllegalAccessException
Throws:
InvocationTargetException
IllegalAccessException

getArgClass

public static final Class getArgClass(Object arg)
Gets the class for a method argument that is appropriate for looking up methods by reflection, by looking for the standard primitive wrapper classes and exchanging for them their underlying primitive class objects. Other classes are passed through unchanged.

Parameters:
arg - an object that is being passed to a method
Returns:
the class to use to look up the method

canWideningTo

public static final boolean canWideningTo(Object object,
                                          Class c)
Tells whether the given object's type can be widen to the given class ---that is, whether the given object can be passed as an argument to a method or constructor with type widdening conversion.


canArgsWideningTo

public static final boolean canArgsWideningTo(Object[] args,
                                              Class[] classes)
Tells whether the given array of objects is compatible with the given array of classes---that is, whether the given array of objects can be passed as arguments to a method or constructor whose parameter types are the given array of classes.


isTypeCompatible

public static final boolean isTypeCompatible(Object object,
                                             Class c)
Tells whether the given object is compatible with the given class ---that is, whether the given object can be passed as an argument to a method or constructor whose parameter type is the given class. If object is null this will return true because null is compatible with any type.


areArgsCompatible

public static final boolean areArgsCompatible(Object[] args,
                                              Class[] classes)
Tells whether the given array of objects is compatible with the given array of classes---that is, whether the given array of objects can be passed as arguments to a method or constructor whose parameter types are the given array of classes.


isMoreSpecific

public static final boolean isMoreSpecific(Class[] classes1,
                                           Class[] classes2)
Tells whether the first array of classes is more specific than the second. Assumes that the two arrays are of the same length.


getModifierString

public static final String getModifierString(int modifiers)

classForName

public static final Class classForName(ExprContext context,
                                       String className)
                                throws ClassNotFoundException
Throws:
ClassNotFoundException

isInstance

public static final boolean isInstance(ExprContext context,
                                       Object value,
                                       String className)
                                throws ExprException
Throws:
ExprException

getPrimitiveDefaultValue

public static Object getPrimitiveDefaultValue(Class forClass)

getConvertedType

public static Object getConvertedType(ExprContext context,
                                      Object target,
                                      Member member,
                                      String propertyName,
                                      Object value,
                                      Class type)

getConvertedTypes

public static boolean getConvertedTypes(ExprContext context,
                                        Object target,
                                        Member member,
                                        String propertyName,
                                        Class[] parameterTypes,
                                        Object[] args,
                                        Object[] newArgs)

getConvertedMethodAndArgs

public static Method getConvertedMethodAndArgs(ExprContext context,
                                               Object target,
                                               String propertyName,
                                               List methods,
                                               Object[] args,
                                               Object[] newArgs)

getConvertedConstructorAndArgs

public static Constructor getConvertedConstructorAndArgs(ExprContext context,
                                                         Object target,
                                                         List constructors,
                                                         Object[] args,
                                                         Object[] newArgs)

getAppropriateMethod

public static Method getAppropriateMethod(ExprContext context,
                                          Object source,
                                          Object target,
                                          String methodName,
                                          String propertyName,
                                          List methods,
                                          Object[] args,
                                          Object[] actualArgs)
Gets the appropriate method to be called for the given target, method name and arguments. If successful this method will return the Method within the target that can be called and the converted arguments in actualArgs. If unsuccessful this method will return null and the actualArgs will be empty.


callAppropriateMethod

public static Object callAppropriateMethod(ExprContext context,
                                           Object source,
                                           Object target,
                                           String methodName,
                                           String propertyName,
                                           List methods,
                                           Object[] args)
                                    throws MethodFailedException
Throws:
MethodFailedException

callStaticMethod

public static final Object callStaticMethod(ExprContext context,
                                            String className,
                                            String methodName,
                                            Object[] args)
                                     throws ExprException,
                                            MethodFailedException
Throws:
ExprException
MethodFailedException

callMethod

public static final Object callMethod(ExprContext context,
                                      Object target,
                                      String methodName,
                                      String propertyName,
                                      Object[] args)
                               throws ExprException,
                                      MethodFailedException
Throws:
ExprException
MethodFailedException

callConstructor

public static final Object callConstructor(ExprContext context,
                                           String className,
                                           Object[] args)
                                    throws ExprException
Throws:
ExprException

getMethodValue

public static final Object getMethodValue(ExprContext context,
                                          Object target,
                                          String propertyName)
                                   throws ExprException,
                                          IllegalAccessException,
                                          NoSuchMethodException,
                                          IntrospectionException
Throws:
ExprException
IllegalAccessException
NoSuchMethodException
IntrospectionException

getMethodValue

public static final Object getMethodValue(ExprContext context,
                                          Object target,
                                          String propertyName,
                                          boolean checkAccessAndExistence)
                                   throws ExprException,
                                          IllegalAccessException,
                                          NoSuchMethodException,
                                          IntrospectionException
If the checkAccessAndExistence flag is true this method will check to see if the method exists and if it is accessible according to the context's MemberAccess. If neither test passes this will return NotFound.

Throws:
ExprException
IllegalAccessException
NoSuchMethodException
IntrospectionException

setMethodValue

public static final boolean setMethodValue(ExprContext context,
                                           Object target,
                                           String propertyName,
                                           Object value)
                                    throws ExprException,
                                           IllegalAccessException,
                                           NoSuchMethodException,
                                           MethodFailedException,
                                           IntrospectionException
Throws:
ExprException
IllegalAccessException
NoSuchMethodException
MethodFailedException
IntrospectionException

setMethodValue

public static final boolean setMethodValue(ExprContext context,
                                           Object target,
                                           String propertyName,
                                           Object value,
                                           boolean checkAccessAndExistence)
                                    throws ExprException,
                                           IllegalAccessException,
                                           NoSuchMethodException,
                                           MethodFailedException,
                                           IntrospectionException
Throws:
ExprException
IllegalAccessException
NoSuchMethodException
MethodFailedException
IntrospectionException

getConstructors

public static final List getConstructors(Class targetClass)

getMethods

public static final Map getMethods(Class targetClass,
                                   boolean staticMethods)

getMethods

public static final List getMethods(Class targetClass,
                                    String name,
                                    boolean staticMethods)

getFields

public static final Map getFields(Class targetClass)

getField

public static final Field getField(Class inClass,
                                   String name)

getFieldValue

public static final Object getFieldValue(ExprContext context,
                                         Object target,
                                         String propertyName)
                                  throws NoSuchFieldException
Throws:
NoSuchFieldException

getFieldValue

public static final Object getFieldValue(ExprContext context,
                                         Object target,
                                         String propertyName,
                                         boolean checkAccessAndExistence)
                                  throws NoSuchFieldException
Throws:
NoSuchFieldException

setFieldValue

public static final boolean setFieldValue(ExprContext context,
                                          Object target,
                                          String propertyName,
                                          Object value)
                                   throws ExprException
Throws:
ExprException

isFieldAccessible

public static final boolean isFieldAccessible(ExprContext context,
                                              Object target,
                                              Class inClass,
                                              String propertyName)

isFieldAccessible

public static final boolean isFieldAccessible(ExprContext context,
                                              Object target,
                                              Field field,
                                              String propertyName)

hasField

public static final boolean hasField(ExprContext context,
                                     Object target,
                                     Class inClass,
                                     String propertyName)

setStaticField

public static final void setStaticField(ExprContext context,
                                        String className,
                                        String fieldName,
                                        Object value)
                                 throws ExprException
Throws:
ExprException

getStaticField

public static final Object getStaticField(ExprContext context,
                                          String className,
                                          String fieldName)
                                   throws ExprException
Throws:
ExprException

getDeclaredMethods

public static final List getDeclaredMethods(Class targetClass,
                                            String propertyName,
                                            boolean findSets)

getGetMethod

public static final Method getGetMethod(ExprContext context,
                                        Class targetClass,
                                        String propertyName)
                                 throws IntrospectionException,
                                        ExprException
Throws:
IntrospectionException
ExprException

isMethodAccessible

public static final boolean isMethodAccessible(ExprContext context,
                                               Object target,
                                               Method method,
                                               String propertyName)

hasGetMethod

public static final boolean hasGetMethod(ExprContext context,
                                         Object target,
                                         Class targetClass,
                                         String propertyName)
                                  throws IntrospectionException,
                                         ExprException
Throws:
IntrospectionException
ExprException

getSetMethod

public static final Method getSetMethod(ExprContext context,
                                        Class targetClass,
                                        String propertyName)
                                 throws IntrospectionException,
                                        ExprException
Throws:
IntrospectionException
ExprException

hasSetMethod

public static final boolean hasSetMethod(ExprContext context,
                                         Object target,
                                         Class targetClass,
                                         String propertyName)
                                  throws IntrospectionException,
                                         ExprException
Throws:
IntrospectionException
ExprException

hasGetProperty

public static final boolean hasGetProperty(ExprContext context,
                                           Object target,
                                           Object oname)
                                    throws IntrospectionException,
                                           ExprException
Throws:
IntrospectionException
ExprException

hasSetProperty

public static final boolean hasSetProperty(ExprContext context,
                                           Object target,
                                           Object oname)
                                    throws IntrospectionException,
                                           ExprException
Throws:
IntrospectionException
ExprException

getPropertyDescriptors

public static final Map getPropertyDescriptors(Class targetClass)
                                        throws IntrospectionException,
                                               ExprException
This method returns the property descriptors for the given class as a Map

Throws:
IntrospectionException
ExprException

getPropertyDescriptor

public static final PropertyDescriptor getPropertyDescriptor(Class targetClass,
                                                             String propertyName)
                                                      throws IntrospectionException,
                                                             ExprException
This method returns a PropertyDescriptor for the given class and property name using a Map lookup (using getPropertyDescriptorsMap()).

Throws:
IntrospectionException
ExprException

getPropertyDescriptorsArray

public static final PropertyDescriptor[] getPropertyDescriptorsArray(Class targetClass)
                                                              throws IntrospectionException
Throws:
IntrospectionException

getPropertyDescriptorFromArray

public static final PropertyDescriptor getPropertyDescriptorFromArray(Class targetClass,
                                                                      String name)
                                                               throws IntrospectionException
Gets the property descriptor with the given name for the target class given.

Parameters:
targetClass - Class for which property descriptor is desired
name - Name of property
Returns:
PropertyDescriptor of the named property or null if the class has no property with the given name
Throws:
IntrospectionException

setMethodAccessor

public static final void setMethodAccessor(Class cls,
                                           MethodAccessor accessor)

getMethodAccessor

public static final MethodAccessor getMethodAccessor(Class cls)
                                              throws ExprException
Throws:
ExprException

getNullHandler

public static final NullHandler getNullHandler(Class cls)
                                        throws ExprException
Throws:
ExprException

setNullHandler

public static final void setNullHandler(Class cls,
                                        NullHandler handler)

getIndexedPropertyType

public static final int getIndexedPropertyType(ExprContext context,
                                               Class sourceClass,
                                               String name)
                                        throws ExprException
Determines the index property type, if any. Returns INDEXED_PROPERTY_NONE if the property is not index-accessible as determined by AribaExpr or JavaBeans. If it is indexable then this will return whether it is a JavaBeans indexed property, conforming to the indexed property patterns (returns INDEXED_PROPERTY_INT) or if it conforms to the AribaExpr arbitrary object indexable (returns INDEXED_PROPERTY_OBJECT).

Throws:
ExprException

getIndexedProperty

public static final Object getIndexedProperty(ExprContext context,
                                              Object source,
                                              String name,
                                              Object index)
                                       throws ExprException
Throws:
ExprException

setIndexedProperty

public static final void setIndexedProperty(ExprContext context,
                                            Object source,
                                            String name,
                                            Object index,
                                            Object value)
                                     throws ExprException
Throws:
ExprException

getEvaluationPool

public static EvaluationPool getEvaluationPool()

getObjectArrayPool

public static ObjectArrayPool getObjectArrayPool()

convert

public static Object convert(Object source)
                      throws ExprException
Throws:
ExprException


AribaWeb User Interface Development Framework
Copyright © 2000-2009 Ariba, Inc. All Rights Reserved.