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 Summary
Modifier and TypeFieldDescriptionstatic final Object[]
protected static final Object[]
protected static final Class[]
static final String
static final MetaClassRegistry
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
append
(Appendable out, Object object) Deprecated.static Object[]
Converts the given object into an array; if its an array then just cast otherwise wrap it in an arrayasIterator
(Object o) static List
static void
assertFailed
(Object expression, Object message) static Object[]
asUnwrappedArray
(Object arguments) static Object
bitwiseNegate
(Object value) static List
createList
(Object[] values) static Map
static List
createRange
(Object from, Object to, boolean inclusive) static List
createRange
(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight) static Script
createScript
(Class scriptClass, Binding context) static Tuple
createTuple
(Object[] array) static String
escapeBackslashes
(String orig) Deprecated.static Matcher
Find the right hand regex within the left hand string and return a matcher.protected static String
Deprecated.static String
Deprecated.static String
Deprecated.static Object
getAttribute
(Object object, String attribute) static Object
getGroovyObjectProperty
(GroovyObject object, String property) static MetaClass
getMetaClass
(Class cls) static MetaClass
getMetaClass
(Object object) static MetaClassRegistry
static Closure
getMethodPointer
(Object object, String methodName) Returns the method pointer for the given object namestatic 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
Deprecated.static Object
invokeClosure
(Object closure, Object arguments) static Object
invokeConstructorOf
(Class type, Object arguments) static Object
invokeConstructorOf
(String klass, 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
static Object
invokeStaticMethod
(Class type, String method, Object arguments) static Object
invokeStaticMethod
(String klass, String methodName, 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
static void
removeClass
(Class clazz) static Object
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 objectstatic 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
static String
toArrayString
(Object[] arguments) Deprecated.static String
toArrayString
(Object[] arguments, int maxSize, boolean safe) Deprecated.static String
toListString
(Collection arg) Deprecated.static String
toListString
(Collection arg, int maxSize) Deprecated.static String
toListString
(Collection arg, int maxSize, boolean safe) Deprecated.static String
toMapString
(Map arg) Deprecated.static String
toMapString
(Map arg, int maxSize) Deprecated.static String
Deprecated.static String
toTypeString
(Object[] arguments) Deprecated.static String
toTypeString
(Object[] arguments, int maxSize) Deprecated.static Object
unaryMinus
(Object value) static Object
static void
Deprecated.
-
Field Details
-
EMPTY_ARGS
-
EMPTY_ARGUMENTS
-
EMPTY_TYPES
-
metaRegistry
-
MAIN_METHOD_NAME
- See Also:
-
-
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
-
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
-
initialCapacity
public 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
-
runScript
-
createScript
-
newScript
public static Script newScript(Class<?> scriptClass, Binding context) throws InstantiationException, IllegalAccessException, InvocationTargetException -
setProperties
Sets the properties on the given object -
createRange
-
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
-
asIterator
-
toString
Deprecated. -
inspect
Deprecated. -
write
Deprecated.- Throws:
IOException
-
append
Deprecated.- Throws:
IOException
-
format
Deprecated. -
format
Deprecated. -
format
@Deprecated public static String format(Object arguments, boolean verbose, int maxSize, boolean safe) Deprecated. -
escapeBackslashes
Deprecated. -
toTypeString
Deprecated. -
toTypeString
Deprecated. -
toMapString
Deprecated. -
toMapString
Deprecated. -
toListString
Deprecated. -
toListString
Deprecated. -
toListString
Deprecated. -
toArrayString
Deprecated. -
toArrayString
Deprecated.
-