railo.runtime.reflection
Class Invoker

java.lang.Object
  extended by railo.runtime.reflection.Invoker

public final class Invoker
extends Object

To invoke a Object on different ways


Constructor Summary
Invoker()
           
 
Method Summary
static Object callGetter(Object o, String prop)
          to invoke a getter Method of a Object
static Object callMethod(Object object, String methodName, Object[] parameters)
          call of a method from given object
static void callSetter(Object o, String prop, Object value)
          to invoke a setter Method of a Object
static Object callStaticMethod(Class staticClass, String methodName, Object[] values)
          call of a static method of a Class
static ConstructorParameterPair getConstructorParameterPairIgnoreCase(Class clazz, Object[] parameters)
          search the matching constructor to defined parameter list, also translate parameters for matching
static Field getFieldIgnoreCase(Class c, String name)
          same like method getField from Class but ignore case from field name
static MethodParameterPair getMethodParameterPairIgnoreCase(Class objectClass, String methodName, Object[] parameters)
          search the matching method to defined Method Name, also translate parameters for matching
static Object getProperty(Object o, String prop)
          to get a visible Property of a object
static Object newInstance(Class clazz, Object[] parameters)
           
static void setProperty(Object o, String prop, Object value)
          assign a value to a visible property of a object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Invoker

public Invoker()
Method Detail

newInstance

public static Object newInstance(Class clazz,
                                 Object[] parameters)
                          throws NoSuchMethodException,
                                 IllegalArgumentException,
                                 InstantiationException,
                                 IllegalAccessException,
                                 InvocationTargetException
Parameters:
clazz -
parameters -
Returns:
new Instance
Throws:
NoSuchMethodException
IllegalArgumentException
InstantiationException
IllegalAccessException
InvocationTargetException

getConstructorParameterPairIgnoreCase

public static ConstructorParameterPair getConstructorParameterPairIgnoreCase(Class clazz,
                                                                             Object[] parameters)
                                                                      throws NoSuchMethodException
search the matching constructor to defined parameter list, also translate parameters for matching

Parameters:
clazz - class to get constructo from
parameters - parameter for the constructor
Returns:
Constructor parameter pair
Throws:
NoSuchMethodException

callMethod

public static Object callMethod(Object object,
                                String methodName,
                                Object[] parameters)
                         throws NoSuchMethodException,
                                IllegalArgumentException,
                                IllegalAccessException,
                                InvocationTargetException
call of a method from given object

Parameters:
object - object to call method from
methodName - name of the method to call
parameters - parameter for method
Returns:
return value of the method
Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
IllegalAccessException
InvocationTargetException

getMethodParameterPairIgnoreCase

public static MethodParameterPair getMethodParameterPairIgnoreCase(Class objectClass,
                                                                   String methodName,
                                                                   Object[] parameters)
                                                            throws NoSuchMethodException
search the matching method to defined Method Name, also translate parameters for matching

Parameters:
objectClass - class object where searching method from
methodName - name of the method to search
parameters - whished parameter list
Returns:
pair with method matching and parameterlist matching
Throws:
NoSuchMethodException

callGetter

public static Object callGetter(Object o,
                                String prop)
                         throws SecurityException,
                                NoSuchMethodException,
                                IllegalArgumentException,
                                IllegalAccessException,
                                InvocationTargetException
to invoke a getter Method of a Object

Parameters:
o - Object to invoke method from
prop - Name of the Method without get
Returns:
return Value of the getter Method
Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
IllegalAccessException
InvocationTargetException

callSetter

public static void callSetter(Object o,
                              String prop,
                              Object value)
                       throws SecurityException,
                              NoSuchMethodException,
                              IllegalArgumentException,
                              IllegalAccessException,
                              InvocationTargetException
to invoke a setter Method of a Object

Parameters:
o - Object to invoke method from
prop - Name of the Method without get
value - Value to set to the Method
Throws:
SecurityException
NoSuchMethodException
IllegalArgumentException
IllegalAccessException
InvocationTargetException

getProperty

public static Object getProperty(Object o,
                                 String prop)
                          throws NoSuchFieldException,
                                 IllegalArgumentException,
                                 IllegalAccessException
to get a visible Property of a object

Parameters:
o - Object to invoke
prop - property to call
Returns:
property value
Throws:
NoSuchFieldException
IllegalArgumentException
IllegalAccessException

setProperty

public static void setProperty(Object o,
                               String prop,
                               Object value)
                        throws IllegalArgumentException,
                               IllegalAccessException,
                               NoSuchFieldException
assign a value to a visible property of a object

Parameters:
o - Object to assign value to his property
prop - name of property
value - Value to assign
Throws:
IllegalArgumentException
IllegalAccessException
NoSuchFieldException

getFieldIgnoreCase

public static Field getFieldIgnoreCase(Class c,
                                       String name)
                                throws NoSuchFieldException
same like method getField from Class but ignore case from field name

Parameters:
c - class to search the field
name - name to search
Returns:
Matching Field
Throws:
NoSuchFieldException

callStaticMethod

public static Object callStaticMethod(Class staticClass,
                                      String methodName,
                                      Object[] values)
                               throws PageException
call of a static method of a Class

Parameters:
staticClass - class how contains method to invoke
methodName - method name to invoke
values - Arguments for the Method
Returns:
return value from method
Throws:
PageException


Copyright © 2012 Railo