Exemplo n.º 1
0
 public static Object bitwiseNegate(Object value) throws Throwable {
   try {
     return InvokerHelper.bitwiseNegate(value);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 2
0
 public static Object unaryPlus(Object value) throws Throwable {
   try {
     return InvokerHelper.unaryPlus(value);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 3
0
 public static void setPropertyOnSuperSpreadSafe(
     Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)
     throws Throwable {
   for (Iterator it = InvokerHelper.asIterator(receiver); it.hasNext(); ) {
     setPropertySafe(messageArgument, senderClass, it.next(), messageName);
   }
 }
Exemplo n.º 4
0
  /**
   * Asserts that the given object can be converted into a collection and iterator of the given size
   */
  protected void assertAsCollection(Object collectionObject, int count) {
    Collection collection = DefaultTypeTransformation.asCollection(collectionObject);
    assertTrue("Collection is not null", collection != null);
    assertEquals("Collection size", count, collection.size());

    assertIterator("collections iterator", collection.iterator(), count);
    assertIterator("InvokerHelper.asIterator", InvokerHelper.asIterator(collectionObject), count);
    assertIterator(
        "InvokerHelper.asIterator(InvokerHelper.asCollection)",
        InvokerHelper.asIterator(collection),
        count);
    assertIterator(
        "InvokerHelper.asIterator(InvokerHelper.asIterator)",
        InvokerHelper.asIterator(InvokerHelper.asIterator(collectionObject)),
        count);
  }
Exemplo n.º 5
0
 public static Object getProperty(Class senderClass, Object receiver, String messageName)
     throws Throwable {
   try {
     return InvokerHelper.getProperty(receiver, messageName);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 6
0
 public static Object getPropertyOnSuperSpreadSafe(
     Class senderClass, GroovyObject receiver, String messageName) throws Throwable {
   List answer = new ArrayList();
   for (Iterator it = InvokerHelper.asIterator(receiver); it.hasNext(); ) {
     answer.add(getPropertySafe(senderClass, it.next(), messageName));
   }
   return answer;
 }
Exemplo n.º 7
0
 public static void setGroovyObjectFieldSpreadSafe(
     Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)
     throws Throwable {
   if (receiver == null) return;
   for (Iterator it = InvokerHelper.asIterator(receiver); it.hasNext(); ) {
     setFieldSafe(messageArgument, senderClass, it.next(), messageName);
   }
 }
Exemplo n.º 8
0
 //  --------------------------------------------------------
 //              normal constructor invocation (via new)
 //  --------------------------------------------------------
 public static Object invokeNewN(Class senderClass, Class receiver, Object arguments)
     throws Throwable {
   try {
     return InvokerHelper.invokeConstructorOf(receiver, arguments);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 9
0
 public static void setPropertyOnSuper(
     Object messageArgument, Class senderClass, GroovyObject receiver, String messageName)
     throws Throwable {
   try {
     InvokerHelper.setAttribute(receiver, messageName, messageArgument);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 10
0
 public static Object getFieldSpreadSafe(Class senderClass, Object receiver, String messageName)
     throws Throwable {
   if (receiver == null) return null;
   List answer = new ArrayList();
   for (Iterator it = InvokerHelper.asIterator(receiver); it.hasNext(); ) {
     answer.add(getFieldSafe(senderClass, it.next(), messageName));
   }
   return answer;
 }
Exemplo n.º 11
0
 //  --------------------------------------------------------
 //                static normal method invocation
 //  --------------------------------------------------------
 public static Object invokeStaticMethodN(
     Class senderClass, Class receiver, String messageName, Object[] messageArguments)
     throws Throwable {
   try {
     return InvokerHelper.invokeStaticMethod(receiver, messageName, messageArguments);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 12
0
 public static Object invokeMethodOnSuperNSpreadSafe(
     Class senderClass, GroovyObject receiver, String messageName, Object[] messageArguments)
     throws Throwable {
   List answer = new ArrayList();
   for (Iterator it = InvokerHelper.asIterator(receiver); it.hasNext(); ) {
     answer.add(invokeMethodNSafe(senderClass, it.next(), messageName, messageArguments));
   }
   return answer;
 }
Exemplo n.º 13
0
 public static void setProperty(
     Object messageArgument, Class senderClass, Object receiver, String messageName)
     throws Throwable {
   try {
     if (receiver == null) receiver = NullObject.getNullObject();
     InvokerHelper.setProperty(receiver, messageName, messageArgument);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 14
0
 public static Object getFieldOnSuper(Class senderClass, Object receiver, String messageName)
     throws Throwable {
   try {
     if (receiver instanceof Class) {
       return InvokerHelper.getAttribute(receiver, messageName);
     } else {
       MetaClass mc = ((GroovyObject) receiver).getMetaClass();
       return mc.getAttribute(senderClass, receiver, messageName, true);
     }
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Exemplo n.º 15
0
 /**
  * Returns the method pointer for the given object name
  *
  * @param object the object containing the method
  * @param methodName the name of the method of interest
  * @return the resulting Closure
  */
 public static Closure getMethodPointer(Object object, String methodName) {
   return InvokerHelper.getMethodPointer(object, methodName);
 }
Exemplo n.º 16
0
 public static MetaClass initMetaClass(Object object) {
   return InvokerHelper.getMetaClass(object.getClass());
 }
Exemplo n.º 17
0
 public static Object spreadMap(Object value) {
   return InvokerHelper.spreadMap(value);
 }
Exemplo n.º 18
0
 public static Object unaryMinus(Object value) throws Throwable {
   return InvokerHelper.unaryMinus(value);
 }
Exemplo n.º 19
0
 public static boolean matchRegex(Object left, Object right) {
   return InvokerHelper.matchRegex(left, right);
 }
Exemplo n.º 20
0
 public static Matcher findRegex(Object left, Object right) throws Throwable {
   return InvokerHelper.findRegex(left, right);
 }
Exemplo n.º 21
0
 // assert
 public static void assertFailed(Object expression, Object message) {
   InvokerHelper.assertFailed(expression, message);
 }
Exemplo n.º 22
0
 public static Map createMap(Object[] values) {
   return InvokerHelper.createMap(values);
 }
Exemplo n.º 23
0
 public static List createList(Object[] values) {
   return InvokerHelper.createList(values);
 }