Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


            GroovyShell interpreter = new GroovyShell( loader, binding, config );

            try
            {
                return interpreter.evaluate( script );
            }
            catch ( ThreadDeath e )
            {
                throw e;
            }
View Full Code Here


        Binding binding = new Binding();
        binding.setVariable("args", args);
        binding.setVariable("properties", project.getProperties());
        GroovyShell shell = new GroovyShell(binding);

        return shell.evaluate(getBody());
    }
   
}
View Full Code Here

     *
     * @param script the script that should pass without any exception thrown
     */
    protected void assertScript(final String script) throws Exception {
        GroovyShell shell = new GroovyShell();
        shell.evaluate(script, getTestClassName());
    }

    protected String getTestClassName() {
        return "TestScript" + getMethodName() + (counter++) + ".groovy";
    }
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);
    }

    /**
     * evaluate expression and make x available inside the expression as 'x'
     * @param expression the Groovy expression to evaluate
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);
    }

    /**
     * evaluate expression and make x,y,z available inside the expression as 'x','y','z'
     * @param expression the Groovy expression to evaluate
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

    if (groovyCode == null) {
      throw new Exception("Groovy code not found");
    }
    logger.debug("Executing groovy code: \n" + groovyCode);
    GroovyShell shell = new GroovyShell();
    Object value = shell.evaluate(groovyCode);
    String toReturn = null;
    if (value != null) {
      toReturn = value.toString();
    }
    logger.debug("OUT: returning " + toReturn);
View Full Code Here

    public void render(Map model, Writer writer) throws RenderingException {
        try {
            long startTime = System.currentTimeMillis();           
            Binding binding = new GroovyRollerBinding(model, writer);
            GroovyShell shell = new GroovyShell(binding);
            shell.evaluate(template.getContents());             
            long endTime = System.currentTimeMillis();

            long renderTime = (endTime - startTime)/1000;
            log.debug("Rendered ["+template.getId()+"] in "+renderTime+" secs");
           
View Full Code Here

    private void renderThrowable(Throwable ex, Writer writer) {
        Binding binding = new Binding();
        binding.setVariable("ex", ex);
        binding.setVariable("out", new PrintWriter(writer));
        GroovyShell shell = new GroovyShell(binding);
        shell.evaluate(
             "s = \"<p><b>Exception</b>: ${ex}<br /><b>Message</b>: ${ex.message}</p>\";"
           +" out.println(s);"
           +" out.flush();");        
    }
}
View Full Code Here

    private void renderThrowable(Throwable ex, Writer writer) {
        Binding binding = new Binding();
        binding.setVariable("ex", ex);
        binding.setVariable("out", new PrintWriter(writer));
        GroovyShell shell = new GroovyShell(binding);
        shell.evaluate(
             "s = \"<p><b>Exception</b>: ${ex}<br /><b>Message</b>: ${ex.message}</p>\";"
           +" out.println(s);"
           +" out.flush();");        
    }
}
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.