org.codehaus.groovy.runtime
Class Invoker

java.lang.Object
  extended by org.codehaus.groovy.runtime.Invoker

public class Invoker
extends Object

A helper class to invoke methods or extract properties on arbitrary Java objects dynamically

Version:
$Revision: 4294 $
Author:
James Strachan

Field Summary
protected static Object[] EMPTY_ARGUMENTS
           
protected static Class[] EMPTY_TYPES
           
 
Constructor Summary
Invoker()
           
 
Method Summary
 Object[] asArray(Object arguments)
          Converts the given object into an array; if its an array then just cast otherwise wrap it in an array
 Object getAttribute(Object object, String attribute)
          Looks up the given attribute (field) on the given object
 MetaClass getMetaClass(Object object)
           
 MetaClassRegistry getMetaRegistry()
           
 Closure getMethodPointer(Object object, String methodName)
          Returns the method pointer for the given object name
 Object getProperty(Object object, String property)
          Looks up the given property of the given object
 Object invokeConstructorOf(Class type, Object arguments)
           
 Object invokeMethod(Object object, String methodName, Object arguments)
          Invokes the given method on the object.
 Object invokeStaticMethod(Class type, String method, Object arguments)
           
 Object invokeSuperMethod(Object object, String methodName, Object arguments)
           
 void removeMetaClass(Class clazz)
           
 void setAttribute(Object object, String attribute, Object newValue)
          Sets the given attribute (field) on the given object
 void setProperty(Object object, String property, Object newValue)
          Sets the property on the given object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARGUMENTS

protected static final Object[] EMPTY_ARGUMENTS

EMPTY_TYPES

protected static final Class[] EMPTY_TYPES
Constructor Detail

Invoker

public Invoker()
Method Detail

getMetaRegistry

public MetaClassRegistry getMetaRegistry()

getMetaClass

public MetaClass getMetaClass(Object object)

invokeMethod

public Object invokeMethod(Object object,
                           String methodName,
                           Object arguments)
Invokes the given method on the object.

Parameters:
object -
methodName -
arguments -
Returns:

invokeSuperMethod

public Object invokeSuperMethod(Object object,
                                String methodName,
                                Object arguments)

invokeStaticMethod

public Object invokeStaticMethod(Class type,
                                 String method,
                                 Object arguments)

invokeConstructorOf

public Object invokeConstructorOf(Class type,
                                  Object arguments)

asArray

public Object[] asArray(Object arguments)
Converts the given object into an array; if its an array then just cast otherwise wrap it in an array


getProperty

public Object getProperty(Object object,
                          String property)
Looks up the given property of the given object


setProperty

public void setProperty(Object object,
                        String property,
                        Object newValue)
Sets the property on the given object


getAttribute

public Object getAttribute(Object object,
                           String attribute)
Looks up the given attribute (field) on the given object


setAttribute

public void setAttribute(Object object,
                         String attribute,
                         Object newValue)
Sets the given attribute (field) on the given object


getMethodPointer

public Closure getMethodPointer(Object object,
                                String methodName)
Returns the method pointer for the given object name


removeMetaClass

public void removeMetaClass(Class clazz)


Copyright © 2003-2010 The Codehaus. All Rights Reserved.