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
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Object[]protected static final Object[]protected static final Class[]static final Stringstatic final MetaClassRegistry
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidappend(Appendable out, Object object) Deprecated.static Object[]Converts the given object into an array; if it's 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 AssertionErrorcreateAssertError(Object expression, Object message) static ListcreateList(Object[] values) static Mapstatic ListcreateRange(Object from, Object to, boolean inclusive) static ListcreateRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight) static ScriptcreateScript(Class scriptClass, Binding context) static TuplecreateTuple(Object[] array) static StringescapeBackslashes(String orig) Deprecated.static MatcherFind the right hand regex within the left hand string and return a matcher.protected static StringDeprecated.static StringDeprecated.static StringDeprecated.static 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 intinitialCapacity(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 StringDeprecated.static 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 Scriptstatic 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) Deprecated.static StringtoArrayString(Object[] arguments, int maxSize, boolean safe) Deprecated.static StringtoListString(Collection arg) Deprecated.static StringtoListString(Collection arg, int maxSize) Deprecated.static StringtoListString(Collection arg, int maxSize, boolean safe) Deprecated.static StringtoMapString(Map arg) Deprecated.static StringtoMapString(Map arg, int maxSize) Deprecated.static StringDeprecated.static StringtoTypeString(Object[] arguments) Deprecated.static StringtoTypeString(Object[] arguments, int maxSize) Deprecated.static ObjectunaryMinus(Object value) static Objectstatic voidDeprecated.
- 
Field Details- 
EMPTY_ARGS
- 
EMPTY_ARGUMENTS
- 
EMPTY_TYPES
- 
metaRegistry
- 
MAIN_METHOD_NAME- See Also:
 
 
- 
- 
Constructor Details- 
InvokerHelperpublic InvokerHelper()
 
- 
- 
Method Details- 
removeClass
- 
invokeMethodSafe
- 
invokeStaticMethodpublic static Object invokeStaticMethod(String klass, String methodName, Object arguments) throws ClassNotFoundException - Throws:
- ClassNotFoundException
 
- 
invokeStaticNoArgumentsMethod
- 
invokeConstructorOfpublic static Object invokeConstructorOf(String klass, Object arguments) throws ClassNotFoundException - Throws:
- ClassNotFoundException
 
- 
invokeNoArgumentsConstructorOf
- 
invokeClosure
- 
asList
- 
getAttribute
- 
setAttribute
- 
getProperty
- 
getPropertySafe
- 
setProperty
- 
setProperty2This 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.
- 
setGroovyObjectPropertyThis 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
- 
setPropertySafe2This 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.
- 
getMethodPointerReturns the method pointer for the given object name
- 
unaryMinus
- 
unaryPlus
- 
findRegexFind the right hand regex within the left hand string and return a matcher.- Parameters:
- left- string to compare
- right- regular expression to compare the string to
 
- 
matchRegexFind the right hand regex within the left hand string and return a matcher.- Parameters:
- left- string to compare
- right- regular expression to compare the string to
 
- 
createTuple
- 
spreadMap
- 
createList
- 
initialCapacitypublic 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)- Parameters:
- initialEntryCnt- the initial entry count
- Returns:
- the initial capacity
 
- 
createMap
- 
assertFailed
- 
createAssertError- Since:
- 4.0.7
 
- 
runScript
- 
createScript
- 
newScriptpublic static Script newScript(Class<? extends Script> scriptClass, Binding context) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException 
- 
setPropertiesSets the properties on the given object
- 
createRange
- 
createRange
- 
bitwiseNegate
- 
getMetaRegistry
- 
getMetaClass
- 
getMetaClass
- 
invokeMethodInvokes the given method on the object.
- 
invokeSuperMethod
- 
invokeStaticMethod
- 
invokeConstructorOf
- 
asArrayConverts the given object into an array; if it's an array then just cast otherwise wrap it in an array
- 
asUnwrappedArray
- 
asIterator
- 
toStringDeprecated.
- 
inspectDeprecated.
- 
writeDeprecated.- Throws:
- IOException
 
- 
appendDeprecated.- Throws:
- IOException
 
- 
formatDeprecated.
- 
formatDeprecated.
- 
format@Deprecated public static String format(Object arguments, boolean verbose, int maxSize, boolean safe) Deprecated.
- 
escapeBackslashesDeprecated.
- 
toTypeStringDeprecated.
- 
toTypeStringDeprecated.
- 
toMapStringDeprecated.
- 
toMapStringDeprecated.
- 
toListStringDeprecated.
- 
toListStringDeprecated.
- 
toListStringDeprecated.
- 
toArrayStringDeprecated.
- 
toArrayStringDeprecated.
 
-