Package groovy.lang

Examples of groovy.lang.Binding


        public Writable make(Map map) {
            if (map == null) {
                throw new IllegalArgumentException("map must not be null");
            }
            return new XmlWritable(script, new Binding(map));
        }
View Full Code Here


    public void testGroovyScriptEngineVsGroovyShell() throws IOException, ResourceException, ScriptException {
        // @todo refactor this path
        File currentDir = new File("./src/test/groovy/bugs");
        String file = "bug1567_script.groovy";

        Binding binding = new Binding();
        GroovyShell shell = new GroovyShell(binding);
        String[] test = null;
        Object result = shell.run(new File(currentDir, file), test);

        String[] roots = new String[]{currentDir.getAbsolutePath()};
        GroovyScriptEngine gse = new GroovyScriptEngine(roots);
        binding = new Binding();
        // a MME was ensued here stating no 't.start()' was available
        // in the script
        gse.run(file, binding);
    }
View Full Code Here

        }

        @Override
        public void run() {
            try {
                Binding b = new Binding();
                b.setVariable("number", count);
                result = (String) this.gse.run(script, b);
            } catch (Throwable t) {
                throw new RuntimeException("problem running script", t);
            }
        }
View Full Code Here

        bindingVariables = new HashMap();
        bindingVariables.put("name", "hans");
    }

    public void testCreateScriptWithNullClass() {
        Script script = InvokerHelper.createScript(null, new Binding(bindingVariables));
        assertEquals(bindingVariables, script.getBinding().getVariables());
    }
View Full Code Here

        String controlProperty = "text";
        String controlValue = "I am a script";
        String code = controlProperty + " = '" + controlValue + "'";
        GroovyCodeSource codeSource = new GroovyCodeSource(code, "testscript", "/groovy/shell");
        Class scriptClass = classLoader.parseClass(codeSource, false);
        Script script = InvokerHelper.createScript(scriptClass, new Binding(bindingVariables));
        assertEquals(bindingVariables, script.getBinding().getVariables());
        script.run();
        assertEquals(controlValue, script.getProperty(controlProperty));
    }
View Full Code Here

            catch (Exception e)
            {
                e.printStackTrace();
            }

            Binding binding = new Binding();
            binding.setVariable("builder", builder);
            script.setBinding(binding);

            script.run();
        }
View Full Code Here

  //Interpreter//
  public void init(Page owner, String zslang) {
    super.init(owner, zslang);

    _global = new Binding(new Variables());
    _ip = new GroovyShell(_global);
  }
View Full Code Here

     * @param in The input stream to use
     * @param out The output stream to use
     * @param err The error stream to use
     */
    public InteractiveShell(final InputStream in, final PrintStream out, final PrintStream err) throws IOException {
        this(null, new Binding(), in, out, err);
    }
View Full Code Here

    /**
     * Displays the current binding used when instantiating the shell.
     */
    private void displayBinding() {
        Binding context = shell.getContext();
        Map variables = context.getVariables();
        Set set = variables.keySet();

        if (set.isEmpty()) {
            out.println(MESSAGES.getMessage("command.binding.binding_empty"));
        }
View Full Code Here

        return result;
    }

    public String evalGroovyExpression( String expression )
    {
        Binding binding = new Binding();
        binding.setVariable( "env", System.getenv() );
        binding.setVariable( "sys", System.getProperties() );
        CompilerConfiguration config = new CompilerConfiguration();
        GroovyShell shell = new GroovyShell( binding, config );
        Object result = shell.evaluate( "return \"" + expression + "\"" );
        if ( result == null )
        {
View Full Code Here

TOP

Related Classes of groovy.lang.Binding

Copyright © 2018 www.massapicom. 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.