Package javax.script

Examples of javax.script.SimpleBindings


        String script =
            "def message\n" +
                "\"message: #{@message}\"\n" +
            "end\n" +
            "message";
        Bindings bindings = new SimpleBindings();
        bindings.put("@message", "What's up?");
        int scope = ScriptContext.ENGINE_SCOPE;
        Object expResult = "message: What's up?";
        instance.setBindings(bindings, scope);
        Object result = instance.eval(script);
        assertEquals(expResult, result);
View Full Code Here


        Object[] args = null;
        String expResult = "Cherry blossom is a round shaped,";
        String result = (String) ((Invocable)instance).invokeMethod(receiver, method, args);
        assertTrue(result.startsWith(expResult));

        Bindings bindings = new SimpleBindings();
        bindings.put("name", "cedar");
        bindings.put("shape", "pyramidal");
        bindings.put("foliage", "evergreen");
        bindings.put("color", "nondescript");
        bindings.put("bloomtime", "April - May");
        instance.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
        filename = basedir + "/test/org/jruby/embed/ruby/tree_given_localvars.rb";
        reader = new FileReader(filename);
        receiver = instance.eval(reader);
        expResult = "Cedar is a pyramidal shaped,";
View Full Code Here

            ScriptEngineManager manager = new ScriptEngineManager();
            instance = manager.getEngineByName("jruby");
        }
        String filename = basedir + "/test/org/jruby/embed/ruby/count_down.rb";
        Reader reader = new FileReader(filename);
        Bindings bindings = new SimpleBindings();
        bindings.put("@month", 6);
        bindings.put("@day", 3);
        instance.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
        Object result = instance.eval(reader, bindings);

        String method = "count_down_birthday";
        bindings.put("@month", 12);
        bindings.put("@day", 3);
        instance.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
        Object[] args = null;
        result = ((Invocable)instance).invokeFunction(method, args);
        assertTrue(((String)result).startsWith("Happy") || ((String)result).startsWith("You have"));
View Full Code Here

    private void init(ClassLoader loader) throws ScriptException {
        nameMap = new HashMap();
        extensionMap = new HashMap();
        mimetypeMap = new HashMap();
        globalMap = new SimpleBindings();
        try {
            factories =
                (HashSet<ScriptEngineFactory>) (new ServiceFinder(loader, service)).getServices();
            if (factories.isEmpty()) {
                System.err.println("no factory");
View Full Code Here

    public void setBindings(Bindings bindings, int scope) {
        context.setBindings(bindings, scope);
    }

    public Bindings createBindings() {
        return new SimpleBindings();
    }
View Full Code Here

        }
        return factory;
    }

    public Bindings createBindings() {
        return new SimpleBindings();
    }
View Full Code Here

        }
        return factory;
    }

    public Bindings createBindings() {
        return new SimpleBindings();
    }
View Full Code Here

            Bindings scriptBindings = this.bindings;

            if(scriptBindings == null)
            {
                scriptBindings = new SimpleBindings(this.arguments);
            }

            return (T)scriptEngine.eval(this.script, scriptBindings);
        }
        catch (ScriptException e)
View Full Code Here

        }
    }

    public <T> T eval(String script, Map<String, Object> arguments, Class<T> returnType)
    {
        return eval(script, new SimpleBindings(arguments), returnType);
    }
View Full Code Here

            script = interpreteScript(script);

            Bindings bindings = null;
            if(arguments != null)
            {
                bindings = new SimpleBindings(arguments);
            }

            if(bindings != null)
            {
                return getCurrentScriptEngineManager().getEngineByName(language).eval(script, bindings);
View Full Code Here

TOP

Related Classes of javax.script.SimpleBindings

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.