Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


public class SeansBug extends TestSupport {

    public void testBug() throws Exception {
        String code = "for (i in 1..10) \n{\n  println(i)\n}";
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }

    public void testMarkupBug() throws Exception {
        String[] lines =
                {
View Full Code Here


                        "    elem2('hello2') ",
                        "    elem3(x:7) ",
                        "}"};
        String code = asCode(lines);
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }

    /**
     * Converts the array of lines of text into one string with newlines
     */
 
View Full Code Here

    binding.setVariable("foo", new Integer(2));
    GroovyShell shell = new GroovyShell(binding);
 
    try {
      Object value =
        shell.evaluate("println 'Hello World!'; x = 123; return foo * 10", "TestScript");
      assert value.equals(new Integer(20));
      assert binding.getVariable("x").equals(new Integer(123));
      System.out.println("value:" + value);
    }
    catch (SyntaxException e) {
View Full Code Here

    }

    private void init() {
        ClassLoader loader = getClass().getClassLoader();
        GroovyShell shell = new GroovyShell(loader);
        shell.evaluate(new InputStreamReader(loader.getResourceAsStream("org/apache/camel/language/groovy/ConfigureCamel.groovy")));

        // TODO compile Groovy as part of build!
        //new ConfigureCamel().run();
    }
}
View Full Code Here

    String result = (String) go.invokeMethod("doStuff", null);
    assertEquals("Do stuff", result);
   
    //GroovyEngine ge = new GroovyEngine();
    GroovyShell sh = new GroovyShell();
    List<?> evaluate = (List<?>) sh.evaluate("[1, 2, 3]");
    System.out.println(evaluate);
  }

}
View Full Code Here

     */
    public static Object me(final String symbol, final Object object, final String expression) throws CompilationFailedException {
        Binding b = new Binding();
        b.setVariable(symbol, object);
        GroovyShell sh = new GroovyShell(b);
        return sh.evaluate(expression);
    }

    /**
     * Evaluates the specified String expression and makes the parameter available inside
     * the script bound to a variable named 'x', returning the result. For example, this
View Full Code Here

    public static Object xy(final Object x, final Object y, final String expression) throws CompilationFailedException {
        Binding b = new Binding();
        b.setVariable("x", x);
        b.setVariable("y", y);
        GroovyShell sh = new GroovyShell(b);
        return sh.evaluate(expression);
    }

    /**
     * Evaluates the specified String expression and makes the first three parameters available inside
     * the script bound to variables named 'x', 'y', and 'z' respectively, returning the result. For
View Full Code Here

        Binding b = new Binding();
        b.setVariable("x", x);
        b.setVariable("y", y);
        b.setVariable("z", z);
        GroovyShell sh = new GroovyShell(b);
        return sh.evaluate(expression);
    }
}
View Full Code Here

public class SeansBug extends TestSupport {

    public void testBug() throws Exception {
        String code = "for (i in 1..10) \n{\n  println(i)\n}";
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }

    public void testMarkupBug() throws Exception {
        String[] lines =
                {
View Full Code Here

                        "    elem2('hello2') ",
                        "    elem3(x:7) ",
                        "}"};
        String code = asCode(lines);
        GroovyShell shell = new GroovyShell();
        shell.evaluate(code);
    }

    /**
     * Converts the array of lines of text into one string with newlines
     */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.