Пример #1
0
 public static Object bitwiseNegate(Object value) throws Throwable {
   try {
     return InvokerHelper.bitwiseNegate(value);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Пример #2
0
 public static Object unaryPlus(Object value) throws Throwable {
   try {
     return InvokerHelper.unaryPlus(value);
   } catch (GroovyRuntimeException gre) {
     throw unwrap(gre);
   }
 }
Пример #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);
   }
 }
Пример #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);
  }
Пример #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);
   }
 }
Пример #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;
 }
Пример #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);
   }
 }
Пример #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);
   }
 }
Пример #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);
   }
 }
Пример #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;
 }
Пример #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);
   }
 }
Пример #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;
 }
Пример #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);
   }
 }
Пример #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);
   }
 }
Пример #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);
 }
Пример #16
0
 public static MetaClass initMetaClass(Object object) {
   return InvokerHelper.getMetaClass(object.getClass());
 }
Пример #17
0
 public static Object spreadMap(Object value) {
   return InvokerHelper.spreadMap(value);
 }
Пример #18
0
 public static Object unaryMinus(Object value) throws Throwable {
   return InvokerHelper.unaryMinus(value);
 }
Пример #19
0
 public static boolean matchRegex(Object left, Object right) {
   return InvokerHelper.matchRegex(left, right);
 }
Пример #20
0
 public static Matcher findRegex(Object left, Object right) throws Throwable {
   return InvokerHelper.findRegex(left, right);
 }
Пример #21
0
 // assert
 public static void assertFailed(Object expression, Object message) {
   InvokerHelper.assertFailed(expression, message);
 }
Пример #22
0
 public static Map createMap(Object[] values) {
   return InvokerHelper.createMap(values);
 }
Пример #23
0
 public static List createList(Object[] values) {
   return InvokerHelper.createList(values);
 }