org.eclipse.epsilon.eol.util
Class ReflectionUtil

java.lang.Object
  extended by org.eclipse.epsilon.eol.util.ReflectionUtil

public class ReflectionUtil
extends java.lang.Object


Constructor Summary
ReflectionUtil()
           
 
Method Summary
static java.lang.Object executeMethod(java.lang.reflect.Method method, java.lang.Object obj, java.lang.Object[] parameters)
           
static java.lang.Object executeMethod(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] parameters, AST ast)
           
static java.lang.Object executeMethod(java.lang.Object obj, java.lang.String methodName, java.lang.Object[] parameters)
           
static java.util.List<java.lang.reflect.Field> getAllInheritedInstanceFields(java.lang.Class<?> klazz)
           
static java.lang.reflect.Field getField(java.lang.Class<?> clazz, java.lang.String fieldName)
          Gets a field of a class using reflection by introspecting the class and its supertype(s)
static java.lang.Object getFieldValue(java.lang.Object object, java.lang.String fieldName)
          Returns the value of a field of an object
static java.lang.reflect.Method getMethodFor(java.lang.Object obj, java.lang.String methodName, java.lang.Object[] parameters, boolean includeInheritedMethods, boolean allowContravariantConversionForParameters)
           
static java.util.Set<java.lang.String> getMethodNames(java.lang.Object obj, boolean includeInheritedMethods)
           
static boolean hasMethods(java.lang.Object obj, java.lang.String methodName)
           
static boolean isInstance(java.lang.Class<?> clazz, java.lang.Object instance)
          Checks if the instance is an instance of clazz Necessary because in Java, int.class != Integer.class etc
static java.lang.String methodToString(java.lang.reflect.Method method)
          Returns a string representation of the method
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionUtil

public ReflectionUtil()
Method Detail

hasMethods

public static boolean hasMethods(java.lang.Object obj,
                                 java.lang.String methodName)

getMethodNames

public static java.util.Set<java.lang.String> getMethodNames(java.lang.Object obj,
                                                             boolean includeInheritedMethods)

getMethodFor

public static java.lang.reflect.Method getMethodFor(java.lang.Object obj,
                                                    java.lang.String methodName,
                                                    java.lang.Object[] parameters,
                                                    boolean includeInheritedMethods,
                                                    boolean allowContravariantConversionForParameters)
Parameters:
allowContravariantConversionForParameters - when false, parameters will have exactly the same class as the arguments to the returned method when true, parameters may have a type that is more specific than the arguments to the returned method

executeMethod

public static java.lang.Object executeMethod(java.lang.Object obj,
                                             java.lang.reflect.Method method,
                                             java.lang.Object[] parameters,
                                             AST ast)
                                      throws EolRuntimeException
Throws:
EolRuntimeException

executeMethod

public static java.lang.Object executeMethod(java.lang.Object obj,
                                             java.lang.String methodName,
                                             java.lang.Object[] parameters)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

executeMethod

public static java.lang.Object executeMethod(java.lang.reflect.Method method,
                                             java.lang.Object obj,
                                             java.lang.Object[] parameters)
                                      throws java.lang.Throwable
Throws:
java.lang.Throwable

methodToString

public static java.lang.String methodToString(java.lang.reflect.Method method)
Returns a string representation of the method

Parameters:
method -
Returns:

getFieldValue

public static java.lang.Object getFieldValue(java.lang.Object object,
                                             java.lang.String fieldName)
Returns the value of a field of an object

Parameters:
object -
fieldName -
Returns:

getField

public static java.lang.reflect.Field getField(java.lang.Class<?> clazz,
                                               java.lang.String fieldName)
Gets a field of a class using reflection by introspecting the class and its supertype(s)

Parameters:
clazz -
fieldName -
Returns:

isInstance

public static boolean isInstance(java.lang.Class<?> clazz,
                                 java.lang.Object instance)
Checks if the instance is an instance of clazz Necessary because in Java, int.class != Integer.class etc

Parameters:
clazz -
instance -
Returns:

getAllInheritedInstanceFields

public static java.util.List<java.lang.reflect.Field> getAllInheritedInstanceFields(java.lang.Class<?> klazz)