org.codehaus.groovy.runtime
Class InvokerHelper

A static helper class to make bytecode generation easier and act as a facade over the Invoker

author:
James Strachan
version:
$Revision: 11920 $

Field Summary
 def EMPTY_ARGS
           
 def EMPTY_ARGUMENTS
           
 def EMPTY_MAIN_ARGS
           
 def EMPTY_TYPES
           
 Invoker SINGLETON
           
 MetaClassRegistry metaRegistry
           
 
Constructor Summary
InvokerHelper()
           
 
Method Summary
static def asArray(Object arguments)
           Converts the given object into an array; if its an array then just cast otherwise wrap it in an array
static Iterator asIterator(Object o)
          
static List asList(Object value)
          
static def asUnwrappedArray(Object arguments)
          
static void assertFailed(Object expression, Object message)
          
static Object bitwiseNegate(Object value)
          
static List createList(def values)
          
static Map createMap(def values)
          
static List createRange(Object from, Object to, boolean inclusive)
          
static Script createScript(Class scriptClass, Binding context)
          
static Tuple createTuple(def array)
          
static Matcher findRegex(Object left, Object right)
           Find the right hand regex within the left hand string and return a matcher.
static String format(Object arguments, boolean verbose)
          
static Object getAttribute(Object object, String attribute)
          
static Object getGroovyObjectProperty(GroovyObject object, String property)
          
static Invoker getInstance()
          
static MetaClass getMetaClass(Object object)
          
static MetaClass getMetaClass(Class cls)
          
static MetaClassRegistry getMetaRegistry()
          
static Closure getMethodPointer(Object object, String methodName)
           Returns the method pointer for the given object name
static Object getProperty(Object object, String property)
          
static Object getPropertySafe(Object object, String property)
          
static String getVersion()
          
static String inspect(Object self)
          
static Object invokeClosure(Object closure, Object arguments)
          
static Object invokeConstructorOf(String klass, Object arguments)
          
static Object invokeConstructorOf(Class type, Object arguments)
          
static Object invokeMethod(Object object, String methodName, Object arguments)
           Invokes the given method on the object.
static Object invokeMethodSafe(Object object, String methodName, Object arguments)
          
static Object invokeNoArgumentsConstructorOf(Class type)
          
static Object invokeNoArgumentsMethod(Object object, String methodName)
          
static Object invokePogoMethod(Object object, String methodName, Object arguments)
          
static Object invokePojoMethod(Object object, String methodName, Object arguments)
          
static Object invokeStaticMethod(String klass, String methodName, Object arguments)
          
static Object invokeStaticMethod(Class type, String method, Object arguments)
          
static Object invokeStaticNoArgumentsMethod(Class type, String methodName)
          
static Object invokeSuperMethod(Object object, String methodName, Object arguments)
          
static boolean matchRegex(Object left, Object right)
           Find the right hand regex within the left hand string and return a matcher.
static void removeClass(Class clazz)
          
static Object runScript(Class scriptClass, def args)
          
static void setAttribute(Object object, String attribute, Object newValue)
          
static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property)
           This is so we don't have to reorder the stack when we call this method.
static void setProperties(Object object, Map map)
           Sets the properties on the given object
static void setProperty(Object object, String property, Object newValue)
          
static void setProperty2(Object newValue, Object object, String property)
           This is so we don't have to reorder the stack when we call this method.
static void setPropertySafe2(Object newValue, Object object, String property)
           This is so we don't have to reorder the stack when we call this method.
static SpreadMap spreadMap(Object value)
          
static String toArrayString(def arguments)
          
static String toListString(Collection arg)
           A helper method to return the string representation of a list with bracket boundaries "[" and "]".
static String toMapString(Map arg)
           A helper method to return the string representation of a map with bracket boundaries "[" and "]".
static String toString(Object arguments)
          
static String toTypeString(def arguments)
           A helper method to format the arguments types as a comma-separated list
static Object unaryMinus(Object value)
          
static Object unaryPlus(Object value)
          
static void write(Writer out, Object object)
           Writes the given object to the given stream
 

Constructor Detail

InvokerHelper

InvokerHelper()


Method Detail

asArray

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


asIterator

public static Iterator asIterator(Object o)


asList

public static List asList(Object value)


asUnwrappedArray

public static def asUnwrappedArray(Object arguments)


assertFailed

public static void assertFailed(Object expression, Object message)


bitwiseNegate

public static Object bitwiseNegate(Object value)


createList

public static List createList(def values)


createMap

public static Map createMap(def values)


createRange

public static List createRange(Object from, Object to, boolean inclusive)


createScript

public static Script createScript(Class scriptClass, Binding context)


createTuple

public static Tuple createTuple(def array)


findRegex

public static Matcher findRegex(Object left, Object right)
Find the right hand regex within the left hand string and return a matcher.
param:
left string to compare
param:
right regular expression to compare the string to


format

static String format(Object arguments, boolean verbose)


getAttribute

public static Object getAttribute(Object object, String attribute)


getGroovyObjectProperty

public static Object getGroovyObjectProperty(GroovyObject object, String property)


getInstance

public static Invoker getInstance()
deprecated:


getMetaClass

public static MetaClass getMetaClass(Object object)


getMetaClass

public static MetaClass getMetaClass(Class cls)


getMetaRegistry

public static MetaClassRegistry getMetaRegistry()


getMethodPointer

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


getProperty

public static Object getProperty(Object object, String property)


getPropertySafe

public static Object getPropertySafe(Object object, String property)


getVersion

public static String getVersion()


inspect

public static String inspect(Object self)


invokeClosure

public static Object invokeClosure(Object closure, Object arguments)


invokeConstructorOf

public static Object invokeConstructorOf(String klass, Object arguments)


invokeConstructorOf

public static Object invokeConstructorOf(Class type, Object arguments)


invokeMethod

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


invokeMethodSafe

public static Object invokeMethodSafe(Object object, String methodName, Object arguments)


invokeNoArgumentsConstructorOf

public static Object invokeNoArgumentsConstructorOf(Class type)


invokeNoArgumentsMethod

public static Object invokeNoArgumentsMethod(Object object, String methodName)
deprecated:


invokePogoMethod

static Object invokePogoMethod(Object object, String methodName, Object arguments)


invokePojoMethod

static Object invokePojoMethod(Object object, String methodName, Object arguments)


invokeStaticMethod

public static Object invokeStaticMethod(String klass, String methodName, Object arguments)


invokeStaticMethod

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


invokeStaticNoArgumentsMethod

public static Object invokeStaticNoArgumentsMethod(Class type, String methodName)


invokeSuperMethod

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


matchRegex

public static boolean matchRegex(Object left, Object right)
Find the right hand regex within the left hand string and return a matcher.
param:
left string to compare
param:
right regular expression to compare the string to


removeClass

public static void removeClass(Class clazz)


runScript

public static Object runScript(Class scriptClass, def args)


setAttribute

public static void setAttribute(Object object, String attribute, Object newValue)


setGroovyObjectProperty

public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property)
This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order.


setProperties

public static void setProperties(Object object, Map map)
Sets the properties on the given object


setProperty

public static void setProperty(Object object, String property, Object newValue)


setProperty2

public static void setProperty2(Object newValue, Object object, String property)
This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order.


setPropertySafe2

public static void setPropertySafe2(Object newValue, Object object, String property)
This is so we don't have to reorder the stack when we call this method. At some point a better name might be in order.


spreadMap

public static SpreadMap spreadMap(Object value)


toArrayString

public static String toArrayString(def arguments)


toListString

public static String toListString(Collection arg)
A helper method to return the string representation of a list with bracket boundaries "[" and "]".


toMapString

public static String toMapString(Map arg)
A helper method to return the string representation of a map with bracket boundaries "[" and "]".


toString

public static String toString(Object arguments)


toTypeString

public static String toTypeString(def arguments)
A helper method to format the arguments types as a comma-separated list


unaryMinus

public static Object unaryMinus(Object value)


unaryPlus

public static Object unaryPlus(Object value)


write

public static void write(Writer out, Object object)
Writes the given object to the given stream