Package org.codehaus.groovy.runtime

# Class InvokerHelper

java.lang.Object
org.codehaus.groovy.runtime.InvokerHelper

public class InvokerHelper extends Object
A static helper class to make bytecode generation easier and act as a facade over the Invoker

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Object[]`
  `EMPTY_ARGS`
  `protected static final Object[]`
  `EMPTY_ARGUMENTS`
  `protected static final Class[]`
  `EMPTY_TYPES`
  `static final String`
  `MAIN_METHOD_NAME`
  `static final MetaClassRegistry`
  `metaRegistry`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InvokerHelper()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `append(Appendable out, Object object)`
  Deprecated.
  `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 void`
  `assertFailed(Object expression, Object message)`
  `static Object[]`
  `asUnwrappedArray(Object arguments)`
  `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 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`
  `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)`
  Deprecated.
  `static String`
  `format(Object arguments, boolean verbose, int maxSize)`
  Deprecated.
  `static String`
  `format(Object arguments, boolean verbose, int maxSize, boolean safe)`
  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`
  `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)`
  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`
  `invokeNoArgumentsConstructorOf(Class type)`
  `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`
  `newScript(Class<?> scriptClass, Binding context)`
  `static void`
  `removeClass(Class clazz)`
  `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)`
  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`
  `toString(Object arguments)`
  Deprecated.
  `static String`
  `toTypeString(Object[] arguments)`
  Deprecated.
  `static String`
  `toTypeString(Object[] arguments, int maxSize)`
  Deprecated.
  `static Object`
  `unaryMinus(Object value)`
  `static Object`
  `unaryPlus(Object value)`
  `static void`
  `write(Writer out, Object object)`
  Deprecated.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### EMPTY_ARGS

    public static final Object[] EMPTY_ARGS

  - ### EMPTY_ARGUMENTS

    protected static final Object[] EMPTY_ARGUMENTS

  - ### EMPTY_TYPES

    protected static final Class[] EMPTY_TYPES

  - ### metaRegistry

    public static final MetaClassRegistry metaRegistry

  - ### MAIN_METHOD_NAME

    public static final String MAIN_METHOD_NAME
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### InvokerHelper

    public InvokerHelper()

- ## Method Details

  - ### removeClass

    public static void removeClass(Class clazz)

  - ### invokeMethodSafe

    public static Object invokeMethodSafe(Object object, String methodName, Object arguments)

  - ### invokeStaticMethod

    public static Object invokeStaticMethod(String klass, String methodName, Object arguments) throws ClassNotFoundException
    Throws:
      `ClassNotFoundException`

  - ### invokeStaticNoArgumentsMethod

    public static Object invokeStaticNoArgumentsMethod(Class type, String methodName)

  - ### invokeConstructorOf

    public static Object invokeConstructorOf(String klass, Object arguments) throws ClassNotFoundException
    Throws:
      `ClassNotFoundException`

  - ### invokeNoArgumentsConstructorOf

    public static Object invokeNoArgumentsConstructorOf(Class type)

  - ### invokeClosure

    public static Object invokeClosure(Object closure, Object arguments)

  - ### asList

    public static List asList(Object value)

  - ### getAttribute

    public static Object getAttribute(Object object, String attribute)

  - ### setAttribute

    public static void setAttribute(Object object, String attribute, Object newValue)

  - ### getProperty

    public static Object getProperty(Object object, String property)

  - ### getPropertySafe

    public static Object getPropertySafe(Object object, String property)

  - ### setProperty

    public static void setProperty(Object object, String property, Object newValue)

  - ### setProperty2

    public 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. At some point a better name might be in order.

  - ### setGroovyObjectProperty

    public 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. At some point a better name might be in order.

  - ### getGroovyObjectProperty

    public static Object getGroovyObjectProperty(GroovyObject object, String property)

  - ### setPropertySafe2

    public 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. At some point a better name might be in order.

  - ### getMethodPointer

    public static Closure getMethodPointer(Object object, String methodName)
    Returns the method pointer for the given object name

  - ### unaryMinus

    public static Object unaryMinus(Object value)

  - ### unaryPlus

    public static Object unaryPlus(Object value)

  - ### findRegex

    public static Matcher findRegex(Object left, Object right)
    Find 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

  - ### matchRegex

    public static boolean matchRegex(Object left, Object right)
    Find 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

    public static Tuple createTuple(Object[] array)

  - ### spreadMap

    public static SpreadMap spreadMap(Object value)

  - ### createList

    public static List createList(Object[] values)

  - ### 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

    public static Map createMap(Object[] values)

  - ### assertFailed

    public static void assertFailed(Object expression, Object message)

  - ### runScript

    public static Object runScript(Class scriptClass, String[] args)

  - ### createScript

    public static Script createScript(Class scriptClass, Binding context)

  - ### newScript

    public static Script newScript(Class<?> scriptClass, Binding context) throws InstantiationException, IllegalAccessException, InvocationTargetException
    Throws:
      `InstantiationException`
      `IllegalAccessException`
      `InvocationTargetException`

  - ### setProperties

    public static void setProperties(Object object, Map map)
    Sets the properties on the given object

  - ### createRange

    public static List createRange(Object from, Object to, boolean exclusiveLeft, boolean exclusiveRight)

  - ### createRange

    public static List createRange(Object from, Object to, boolean inclusive)

  - ### bitwiseNegate

    public static Object bitwiseNegate(Object value)

  - ### getMetaRegistry

    public static MetaClassRegistry getMetaRegistry()

  - ### getMetaClass

    public static MetaClass getMetaClass(Object object)

  - ### getMetaClass

    public static MetaClass getMetaClass(Class cls)

  - ### invokeMethod

    public static Object invokeMethod(Object object, String methodName, Object arguments)
    Invokes the given method on the object.

  - ### invokeSuperMethod

    public static Object invokeSuperMethod(Object object, String methodName, Object arguments)

  - ### invokeStaticMethod

    public static Object invokeStaticMethod(Class type, String method, Object arguments)

  - ### invokeConstructorOf

    public static Object invokeConstructorOf(Class type, Object arguments)

  - ### asArray

    public 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

  - ### asUnwrappedArray

    public static Object[] asUnwrappedArray(Object arguments)

  - ### asIterator

    public static Iterator<Object> asIterator(Object o)

  - ### toString

    @Deprecated public static String toString(Object arguments)
    Deprecated.

  - ### inspect

    @Deprecated public static String inspect(Object self)
    Deprecated.

  - ### write

    @Deprecated public static void write(Writer out, Object object) throws IOException
    Deprecated.
    Throws:
      `IOException`

  - ### append

    @Deprecated public static void append(Appendable out, Object object) throws IOException
    Deprecated.
    Throws:
      `IOException`

  - ### format

    @Deprecated protected static String format(Object arguments, boolean verbose)
    Deprecated.

  - ### format

    @Deprecated public static String format(Object arguments, boolean verbose, int maxSize)
    Deprecated.

  - ### format

    @Deprecated public static String format(Object arguments, boolean verbose, int maxSize, boolean safe)
    Deprecated.

  - ### escapeBackslashes

    @Deprecated public static String escapeBackslashes(String orig)
    Deprecated.

  - ### toTypeString

    @Deprecated public static String toTypeString(Object[] arguments)
    Deprecated.

  - ### toTypeString

    @Deprecated public static String toTypeString(Object[] arguments, int maxSize)
    Deprecated.

  - ### toMapString

    @Deprecated public static String toMapString(Map arg)
    Deprecated.

  - ### toMapString

    @Deprecated public static String toMapString(Map arg, int maxSize)
    Deprecated.

  - ### toListString

    @Deprecated public static String toListString(Collection arg)
    Deprecated.

  - ### toListString

    @Deprecated public static String toListString(Collection arg, int maxSize)
    Deprecated.

  - ### toListString

    @Deprecated public static String toListString(Collection arg, int maxSize, boolean safe)
    Deprecated.

  - ### toArrayString

    @Deprecated public static String toArrayString(Object[] arguments)
    Deprecated.

  - ### toArrayString

    @Deprecated public static String toArrayString(Object[] arguments, int maxSize, boolean safe)
    Deprecated.