Package org.codehaus.groovy.runtime
Class InvokerHelper
java.lang.Object
org.codehaus.groovy.runtime.InvokerHelper
A static helper class to make bytecode generation easier and act as a facade over the Invoker
- Version:
- $Revision$
- Author:
- James Strachan
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Object[]protected static final Object[]protected static final Class[]static final MetaClassRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]Converts the given object into an array; if its an array then just cast otherwise wrap it in an arrayasIterator(Object o) static Liststatic voidassertFailed(Object expression, Object message) static Object[]asUnwrappedArray(Object arguments) static ObjectbitwiseNegate(Object value) static ListcreateList(Object[] values) static Mapstatic ListcreateRange(Object from, Object to, boolean inclusive) static ScriptcreateScript(Class scriptClass, Binding context) static TuplecreateTuple(Object[] array) static MatcherFind the right hand regex within the left hand string and return a matcher.protected static Stringstatic Stringstatic ObjectgetAttribute(Object object, String attribute) static ObjectgetGroovyObjectProperty(GroovyObject object, String property) static MetaClassgetMetaClass(Class cls) static MetaClassgetMetaClass(Object object) static MetaClassRegistrystatic ClosuregetMethodPointer(Object object, String methodName) Returns the method pointer for the given object namestatic ObjectgetProperty(Object object, String property) static ObjectgetPropertySafe(Object object, String property) static StringDeprecated.Use GroovySystem version instead.static Stringstatic ObjectinvokeClosure(Object closure, Object arguments) static ObjectinvokeConstructorOf(Class type, Object arguments) static ObjectinvokeConstructorOf(String klass, Object arguments) static ObjectinvokeMethod(Object object, String methodName, Object arguments) Invokes the given method on the object.static ObjectinvokeMethodSafe(Object object, String methodName, Object arguments) static Objectstatic ObjectinvokeStaticMethod(Class type, String method, Object arguments) static ObjectinvokeStaticMethod(String klass, String methodName, Object arguments) static ObjectinvokeStaticNoArgumentsMethod(Class type, String methodName) static ObjectinvokeSuperMethod(Object object, String methodName, Object arguments) static booleanmatchRegex(Object left, Object right) Find the right hand regex within the left hand string and return a matcher.static voidremoveClass(Class clazz) static Objectstatic voidsetAttribute(Object object, String attribute, Object newValue) static voidsetGroovyObjectProperty(Object newValue, GroovyObject object, String property) This is so we don't have to reorder the stack when we call this method.static voidsetProperties(Object object, Map map) Sets the properties on the given objectstatic voidsetProperty(Object object, String property, Object newValue) static voidsetProperty2(Object newValue, Object object, String property) This is so we don't have to reorder the stack when we call this method.static voidsetPropertySafe2(Object newValue, Object object, String property) This is so we don't have to reorder the stack when we call this method.static SpreadMapstatic StringtoArrayString(Object[] arguments) A helper method to return the string representation of an array of objects with brace boundaries "{" and "}".static StringtoListString(Collection arg) A helper method to return the string representation of a list with bracket boundaries "[" and "]".static StringtoListString(Collection arg, int maxSize) A helper method to return the string representation of a list with bracket boundaries "[" and "]".static StringtoMapString(Map arg) A helper method to return the string representation of a map with bracket boundaries "[" and "]".static StringtoMapString(Map arg, int maxSize) A helper method to return the string representation of a map with bracket boundaries "[" and "]".static Stringstatic StringtoTypeString(Object[] arguments) A helper method to format the arguments types as a comma-separated list.static ObjectunaryMinus(Object value) static Objectstatic voidWrites the given object to the given stream
-
Field Details
-
EMPTY_ARGS
-
EMPTY_ARGUMENTS
-
EMPTY_TYPES
-
metaRegistry
-
-
Constructor Details
-
InvokerHelper
public InvokerHelper()
-
-
Method Details
-
removeClass
-
invokeMethodSafe
-
invokeStaticMethod
public static Object invokeStaticMethod(String klass, String methodName, Object arguments) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
invokeStaticNoArgumentsMethod
-
invokeConstructorOf
public static Object invokeConstructorOf(String klass, Object arguments) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
invokeNoArgumentsConstructorOf
-
invokeClosure
-
asList
-
toString
-
inspect
-
getAttribute
-
setAttribute
-
getProperty
-
getPropertySafe
-
setProperty
-
setProperty2
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. -
setGroovyObjectProperty
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. -
getGroovyObjectProperty
-
setPropertySafe2
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. -
getMethodPointer
Returns the method pointer for the given object name -
unaryMinus
-
unaryPlus
-
findRegex
Find the right hand regex within the left hand string and return a matcher.- Parameters:
left- string to compareright- regular expression to compare the string to
-
matchRegex
Find the right hand regex within the left hand string and return a matcher.- Parameters:
left- string to compareright- regular expression to compare the string to
-
createTuple
-
spreadMap
-
createList
-
createMap
-
assertFailed
-
runScript
-
createScript
-
setProperties
Sets the properties on the given object -
getVersion
Deprecated.Use GroovySystem version instead. -
write
Writes the given object to the given stream- Throws:
IOException
-
asIterator
-
format
-
format
-
toTypeString
A helper method to format the arguments types as a comma-separated list.- Parameters:
arguments- the type to process- Returns:
- the string representation of the type
-
toMapString
A helper method to return the string representation of a map with bracket boundaries "[" and "]".- Parameters:
arg- the map to process- Returns:
- the string representation of the map
-
toMapString
A helper method to return the string representation of a map with bracket boundaries "[" and "]".- Parameters:
arg- the map to processmaxSize- stop after approximately this many characters and append '...'- Returns:
- the string representation of the map
-
toListString
A helper method to return the string representation of a list with bracket boundaries "[" and "]".- Parameters:
arg- the collection to process- Returns:
- the string representation of the collection
-
toListString
A helper method to return the string representation of a list with bracket boundaries "[" and "]".- Parameters:
arg- the collection to processmaxSize- stop after approximately this many characters and append '...'- Returns:
- the string representation of the collection
-
toArrayString
A helper method to return the string representation of an array of objects with brace boundaries "{" and "}".- Parameters:
arguments- the array to process- Returns:
- the string representation of the array
-
createRange
-
bitwiseNegate
-
getMetaRegistry
-
getMetaClass
-
getMetaClass
-
invokeMethod
Invokes the given method on the object. -
invokeSuperMethod
-
invokeStaticMethod
-
invokeConstructorOf
-
asArray
Converts the given object into an array; if its an array then just cast otherwise wrap it in an array -
asUnwrappedArray
-