ua.gradsoft.termware.util
Class JavaLangReflectHelper

java.lang.Object
  extended by ua.gradsoft.termware.util.JavaLangReflectHelper

public class JavaLangReflectHelper
extends Object

Helper class for work with java language reflection interfaces.


Constructor Summary
JavaLangReflectHelper()
           
 
Method Summary
static Method findClassMethodByNameAndArity(Class objectClass, String name, int arity)
          find method in class objectClass or it superclass with given name and arity.
static List<Class> getAllSuperClasses(Class aClass)
           
static List<Class<?>> getAllSuperInterfaces(Class<?> aClass)
           
static Class getBigDecimalClass()
           
static Class getBigIntegerClass()
           
static Class getCharacterClass()
           
static Object[] getEmptyArray()
           
static Class getObjectArrayClass()
           
static Class getStringClass()
           
static Object instantiateObject(String className)
          instantiate Object with given class name using empty constructor
static Object instantiateObject(String className, Class argClass, Object arg)
          instantiate object with given class name, using constructor with one argument of class argClass.
static Object invokeObjectMethod(Object o, Method m)
           
static Object invokeObjectMethod(Object o, Method m, Object[] arguments)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaLangReflectHelper

public JavaLangReflectHelper()
Method Detail

getStringClass

public static final Class getStringClass()

getCharacterClass

public static final Class getCharacterClass()

getBigIntegerClass

public static final Class getBigIntegerClass()

getBigDecimalClass

public static final Class getBigDecimalClass()

getObjectArrayClass

public static final Class getObjectArrayClass()

getEmptyArray

public static final Object[] getEmptyArray()

getAllSuperInterfaces

public static final List<Class<?>> getAllSuperInterfaces(Class<?> aClass)

getAllSuperClasses

public static final List<Class> getAllSuperClasses(Class aClass)

instantiateObject

public static Object instantiateObject(String className)
                                throws InvocationException
instantiate Object with given class name using empty constructor

Throws:
InvocationException

instantiateObject

public static Object instantiateObject(String className,
                                       Class argClass,
                                       Object arg)
                                throws InvocationException
instantiate object with given class name, using constructor with one argument of class argClass.

Throws:
InvocationException

findClassMethodByNameAndArity

public static Method findClassMethodByNameAndArity(Class objectClass,
                                                   String name,
                                                   int arity)
                                            throws JavaMethodNotFoundException
find method in class objectClass or it superclass with given name and arity. Method in result have name name and number of arguments arity or arity+1 . If number of parameters is arity+1 then first parameter have type TransformationContext .

Returns:
method with matching name and arity.
Throws:
JavaMethodNotFoundException - if such method does not exists.

invokeObjectMethod

public static Object invokeObjectMethod(Object o,
                                        Method m)
                                 throws InvocationException
Throws:
InvocationException

invokeObjectMethod

public static Object invokeObjectMethod(Object o,
                                        Method m,
                                        Object[] arguments)
                                 throws InvocationException
Throws:
InvocationException