public class InvokerHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.Object[] |
EMPTY_ARGS |
protected static java.lang.Object[] |
EMPTY_ARGUMENTS |
protected static java.lang.Class[] |
EMPTY_TYPES |
static MetaClassRegistry |
metaRegistry |
Constructor and Description |
---|
InvokerHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
append(java.lang.Appendable out,
java.lang.Object object)
Appends an object to an Appendable using Groovy's default representation for the object.
|
static java.lang.Object[] |
asArray(java.lang.Object arguments)
Converts the given object into an array; if its an array then just
cast otherwise wrap it in an array
|
static java.util.Iterator<java.lang.Object> |
asIterator(java.lang.Object o) |
static java.util.List |
asList(java.lang.Object value) |
static void |
assertFailed(java.lang.Object expression,
java.lang.Object message) |
static java.lang.Object[] |
asUnwrappedArray(java.lang.Object arguments) |
static java.lang.Object |
bitwiseNegate(java.lang.Object value) |
static java.util.List |
createList(java.lang.Object[] values) |
static java.util.Map |
createMap(java.lang.Object[] values) |
static java.util.List |
createRange(java.lang.Object from,
java.lang.Object to,
boolean inclusive) |
static Script |
createScript(java.lang.Class scriptClass,
Binding context) |
static Tuple |
createTuple(java.lang.Object[] array) |
static java.lang.String |
escapeBackslashes(java.lang.String orig) |
static java.util.regex.Matcher |
findRegex(java.lang.Object left,
java.lang.Object right)
Find the right hand regex within the left hand string and return a matcher.
|
protected static java.lang.String |
format(java.lang.Object arguments,
boolean verbose) |
static java.lang.String |
format(java.lang.Object arguments,
boolean verbose,
int maxSize) |
static java.lang.Object |
getAttribute(java.lang.Object object,
java.lang.String attribute) |
static java.lang.Object |
getGroovyObjectProperty(GroovyObject object,
java.lang.String property) |
static MetaClass |
getMetaClass(java.lang.Class cls) |
static MetaClass |
getMetaClass(java.lang.Object object) |
static MetaClassRegistry |
getMetaRegistry() |
static Closure |
getMethodPointer(java.lang.Object object,
java.lang.String methodName)
Returns the method pointer for the given object name
|
static java.lang.Object |
getProperty(java.lang.Object object,
java.lang.String property) |
static java.lang.Object |
getPropertySafe(java.lang.Object object,
java.lang.String property) |
static java.lang.String |
inspect(java.lang.Object self) |
static java.lang.Object |
invokeClosure(java.lang.Object closure,
java.lang.Object arguments) |
static java.lang.Object |
invokeConstructorOf(java.lang.Class type,
java.lang.Object arguments) |
static java.lang.Object |
invokeConstructorOf(java.lang.String klass,
java.lang.Object arguments) |
static java.lang.Object |
invokeMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object arguments)
Invokes the given method on the object.
|
static java.lang.Object |
invokeMethodSafe(java.lang.Object object,
java.lang.String methodName,
java.lang.Object arguments) |
static java.lang.Object |
invokeNoArgumentsConstructorOf(java.lang.Class type) |
static java.lang.Object |
invokeStaticMethod(java.lang.Class type,
java.lang.String method,
java.lang.Object arguments) |
static java.lang.Object |
invokeStaticMethod(java.lang.String klass,
java.lang.String methodName,
java.lang.Object arguments) |
static java.lang.Object |
invokeStaticNoArgumentsMethod(java.lang.Class type,
java.lang.String methodName) |
static java.lang.Object |
invokeSuperMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object arguments) |
static boolean |
matchRegex(java.lang.Object left,
java.lang.Object right)
Find the right hand regex within the left hand string and return a matcher.
|
static Script |
newScript(java.lang.Class scriptClass,
Binding context) |
static void |
removeClass(java.lang.Class clazz) |
static java.lang.Object |
runScript(java.lang.Class scriptClass,
java.lang.String[] args) |
static void |
setAttribute(java.lang.Object object,
java.lang.String attribute,
java.lang.Object newValue) |
static void |
setGroovyObjectProperty(java.lang.Object newValue,
GroovyObject object,
java.lang.String property)
This is so we don't have to reorder the stack when we call this method.
|
static void |
setProperties(java.lang.Object object,
java.util.Map map)
Sets the properties on the given object
|
static void |
setProperty(java.lang.Object object,
java.lang.String property,
java.lang.Object newValue) |
static void |
setProperty2(java.lang.Object newValue,
java.lang.Object object,
java.lang.String property)
This is so we don't have to reorder the stack when we call this method.
|
static void |
setPropertySafe2(java.lang.Object newValue,
java.lang.Object object,
java.lang.String property)
This is so we don't have to reorder the stack when we call this method.
|
static SpreadMap |
spreadMap(java.lang.Object value) |
static java.lang.String |
toArrayString(java.lang.Object[] arguments)
A helper method to return the string representation of an array of objects
with brace boundaries "[" and "]".
|
static java.lang.String |
toArrayString(java.lang.Object[] arguments,
int maxSize,
boolean safe)
A helper method to return the string representation of an array of objects
with brace boundaries "[" and "]".
|
static java.lang.String |
toListString(java.util.Collection arg)
A helper method to return the string representation of a list with bracket boundaries "[" and "]".
|
static java.lang.String |
toListString(java.util.Collection arg,
int maxSize)
A helper method to return the string representation of a list with bracket boundaries "[" and "]".
|
static java.lang.String |
toListString(java.util.Collection arg,
int maxSize,
boolean safe)
A helper method to return the string representation of a list with bracket boundaries "[" and "]".
|
static java.lang.String |
toMapString(java.util.Map arg)
A helper method to return the string representation of a map with bracket boundaries "[" and "]".
|
static java.lang.String |
toMapString(java.util.Map arg,
int maxSize)
A helper method to return the string representation of a map with bracket boundaries "[" and "]".
|
static java.lang.String |
toString(java.lang.Object arguments) |
static java.lang.String |
toTypeString(java.lang.Object[] arguments)
A helper method to format the arguments types as a comma-separated list.
|
static java.lang.Object |
unaryMinus(java.lang.Object value) |
static java.lang.Object |
unaryPlus(java.lang.Object value) |
static void |
write(java.io.Writer out,
java.lang.Object object)
Writes an object to a Writer using Groovy's default representation for the object.
|
public static final java.lang.Object[] EMPTY_ARGS
protected static final java.lang.Object[] EMPTY_ARGUMENTS
protected static final java.lang.Class[] EMPTY_TYPES
public static final MetaClassRegistry metaRegistry
public static void removeClass(java.lang.Class clazz)
public static java.lang.Object invokeMethodSafe(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)
public static java.lang.Object invokeStaticMethod(java.lang.String klass, java.lang.String methodName, java.lang.Object arguments) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.Object invokeStaticNoArgumentsMethod(java.lang.Class type, java.lang.String methodName)
public static java.lang.Object invokeConstructorOf(java.lang.String klass, java.lang.Object arguments) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.Object invokeNoArgumentsConstructorOf(java.lang.Class type)
public static java.lang.Object invokeClosure(java.lang.Object closure, java.lang.Object arguments)
public static java.util.List asList(java.lang.Object value)
public static java.lang.String toString(java.lang.Object arguments)
public static java.lang.String inspect(java.lang.Object self)
public static java.lang.Object getAttribute(java.lang.Object object, java.lang.String attribute)
public static void setAttribute(java.lang.Object object, java.lang.String attribute, java.lang.Object newValue)
public static java.lang.Object getProperty(java.lang.Object object, java.lang.String property)
public static java.lang.Object getPropertySafe(java.lang.Object object, java.lang.String property)
public static void setProperty(java.lang.Object object, java.lang.String property, java.lang.Object newValue)
public static void setProperty2(java.lang.Object newValue, java.lang.Object object, java.lang.String property)
public static void setGroovyObjectProperty(java.lang.Object newValue, GroovyObject object, java.lang.String property)
public static java.lang.Object getGroovyObjectProperty(GroovyObject object, java.lang.String property)
public static void setPropertySafe2(java.lang.Object newValue, java.lang.Object object, java.lang.String property)
public static Closure getMethodPointer(java.lang.Object object, java.lang.String methodName)
public static java.lang.Object unaryMinus(java.lang.Object value)
public static java.lang.Object unaryPlus(java.lang.Object value)
public static java.util.regex.Matcher findRegex(java.lang.Object left, java.lang.Object right)
left
- string to compareright
- regular expression to compare the string topublic static boolean matchRegex(java.lang.Object left, java.lang.Object right)
left
- string to compareright
- regular expression to compare the string topublic static Tuple createTuple(java.lang.Object[] array)
public static SpreadMap spreadMap(java.lang.Object value)
public static java.util.List createList(java.lang.Object[] values)
public static java.util.Map createMap(java.lang.Object[] values)
public static void assertFailed(java.lang.Object expression, java.lang.Object message)
public static java.lang.Object runScript(java.lang.Class scriptClass, java.lang.String[] args)
public static Script newScript(java.lang.Class scriptClass, Binding context) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static void setProperties(java.lang.Object object, java.util.Map map)
public static void write(java.io.Writer out, java.lang.Object object) throws java.io.IOException
java.io.IOException
public static void append(java.lang.Appendable out, java.lang.Object object) throws java.io.IOException
java.io.IOException
public static java.util.Iterator<java.lang.Object> asIterator(java.lang.Object o)
protected static java.lang.String format(java.lang.Object arguments, boolean verbose)
public static java.lang.String format(java.lang.Object arguments, boolean verbose, int maxSize)
public static java.lang.String escapeBackslashes(java.lang.String orig)
public static java.lang.String toTypeString(java.lang.Object[] arguments)
arguments
- the type to processpublic static java.lang.String toMapString(java.util.Map arg)
arg
- the map to processpublic static java.lang.String toMapString(java.util.Map arg, int maxSize)
arg
- the map to processmaxSize
- stop after approximately this many characters and append '...'public static java.lang.String toListString(java.util.Collection arg)
arg
- the collection to processpublic static java.lang.String toListString(java.util.Collection arg, int maxSize)
arg
- the collection to processmaxSize
- stop after approximately this many characters and append '...'public static java.lang.String toListString(java.util.Collection arg, int maxSize, boolean safe)
arg
- the collection to processmaxSize
- stop after approximately this many characters and append '...'safe
- whether to use a default object representation for any item in the collection if an exception occurs when generating its toStringpublic static java.lang.String toArrayString(java.lang.Object[] arguments)
arguments
- the array to processpublic static java.lang.String toArrayString(java.lang.Object[] arguments, int maxSize, boolean safe)
arguments
- the array to processmaxSize
- stop after approximately this many characters and append '...'safe
- whether to use a default object representation for any item in the array if an exception occurs when generating its toStringpublic static java.util.List createRange(java.lang.Object from, java.lang.Object to, boolean inclusive)
public static java.lang.Object bitwiseNegate(java.lang.Object value)
public static MetaClassRegistry getMetaRegistry()
public static MetaClass getMetaClass(java.lang.Object object)
public static MetaClass getMetaClass(java.lang.Class cls)
public static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)
public static java.lang.Object invokeSuperMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)
public static java.lang.Object invokeStaticMethod(java.lang.Class type, java.lang.String method, java.lang.Object arguments)
public static java.lang.Object invokeConstructorOf(java.lang.Class type, java.lang.Object arguments)
public static java.lang.Object[] asArray(java.lang.Object arguments)
public static java.lang.Object[] asUnwrappedArray(java.lang.Object arguments)