public class InvokerHelper extends Object
A static helper class to make bytecode generation easier and act as a facade over the Invoker
Modifiers | Name | Description |
---|---|---|
static Object[] |
EMPTY_ARGS |
|
protected static Object[] |
EMPTY_ARGUMENTS |
|
protected static Class[] |
EMPTY_TYPES |
|
static String |
MAIN_METHOD_NAME |
|
static MetaClassRegistry |
metaRegistry |
Type Params | Return Type | Name and description |
---|---|---|
|
static void |
append(Appendable out, Object object) Appends an object to an Appendable using Groovy's default representation for the object. |
|
static Object[] |
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<Object> |
asIterator(Object o) |
|
static List |
asList(Object value) |
|
static Object[] |
asUnwrappedArray(Object arguments) |
|
static void |
assertFailed(Object expression, Object message) |
|
static Object |
bitwiseNegate(Object value) |
|
static List |
createList(Object[] values) |
|
static Map |
createMap(Object[] values) |
|
static List |
createRange(Object from, Object to, boolean inclusive) |
|
static Script |
createScript(Class scriptClass, Binding context) |
|
static Tuple |
createTuple(Object[] array) |
|
static String |
escapeBackslashes(String orig) |
|
static Matcher |
findRegex(Object left, Object right) Find the right hand regex within the left hand string and return a matcher. |
|
protected static String |
format(Object arguments, boolean verbose) |
|
static String |
format(Object arguments, boolean verbose, int maxSize) |
|
static String |
format(Object arguments, boolean verbose, int maxSize, boolean safe) |
|
static Object |
getAttribute(Object object, String attribute) |
|
static Object |
getGroovyObjectProperty(GroovyObject object, String property) |
|
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 int |
initialCapacity(int initialEntryCnt) According to the initial entry count, calculate the initial capacity of hash map, which is power of 2 (SEE https://stackoverflow.com/questions/8352378/why-does-hashmap-require-that-the-initial-capacity-be-a-power-of-two) |
|
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 |
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 Script |
newScript(Class<?> scriptClass, Binding context) |
|
static void |
removeClass(Class clazz) |
|
Object |
run() |
|
static Object |
runScript(Class scriptClass, String[] 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(Object[] arguments) A helper method to return the string representation of an array of objects with brace boundaries "[" and "]". |
|
static String |
toArrayString(Object[] arguments, int maxSize, boolean safe) A helper method to return the string representation of an array of objects with brace boundaries "[" and "]". |
|
static String |
toListString(Collection arg) A helper method to return the string representation of a list with bracket boundaries "[" and "]". |
|
static String |
toListString(Collection arg, int maxSize) A helper method to return the string representation of a list with bracket boundaries "[" and "]". |
|
static String |
toListString(Collection arg, int maxSize, boolean safe) 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 |
toMapString(Map arg, int maxSize) A helper method to return the string representation of a map with bracket boundaries "[" and "]". |
|
static String |
toString(Object arguments) |
|
static String |
toTypeString(Object[] arguments) A helper method to format the arguments types as a comma-separated list. |
|
static String |
toTypeString(Object[] arguments, int maxSize) 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 an object to a Writer using Groovy's default representation for the object. |
Appends an object to an Appendable using Groovy's default representation for the object.
Converts the given object into an array; if its an array then just cast otherwise wrap it in an array
Find the right hand regex within the left hand string and return a matcher.
left
- string to compareright
- regular expression to compare the string toReturns the method pointer for the given object name
According to the initial entry count, calculate the initial capacity of hash map, which is power of 2 (SEE https://stackoverflow.com/questions/8352378/why-does-hashmap-require-that-the-initial-capacity-be-a-power-of-two)
initialEntryCnt
- the initial entry countInvokes the given method on the object.
Find the right hand regex within the left hand string and return a matcher.
left
- string to compareright
- regular expression to compare the string toThis 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.
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.
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.
A helper method to return the string representation of an array of objects with brace boundaries "[" and "]".
arguments
- the array to processA helper method to return the string representation of an array of objects with brace boundaries "[" and "]".
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 toStringA helper method to return the string representation of a list with bracket boundaries "[" and "]".
arg
- the collection to processA helper method to return the string representation of a list with bracket boundaries "[" and "]".
arg
- the collection to processmaxSize
- stop after approximately this many characters and append '...'A helper method to return the string representation of a list with bracket boundaries "[" and "]".
arg
- the collection to processmaxSize
- stop after approximately this many characters and append '...', -1 means don't stopsafe
- whether to use a default object representation for any item in the collection if an exception occurs when generating its toStringA helper method to return the string representation of a map with bracket boundaries "[" and "]".
arg
- the map to processA helper method to return the string representation of a map with bracket boundaries "[" and "]".
arg
- the map to processmaxSize
- stop after approximately this many characters and append '...', -1 means don't stopA helper method to format the arguments types as a comma-separated list.
arguments
- the type to processA helper method to format the arguments types as a comma-separated list.
arguments
- the type to processmaxSize
- stop after approximately this many characters and append '...', -1 means don't stop