Package javax.script

Examples of javax.script.Bindings


    private String[] getAllKeys() {
        ArrayList<String> list = new ArrayList<String>();
        synchronized (context) {
            for (int scope : context.getScopes()) {
                Bindings bindings = context.getBindings(scope);
                if (bindings != null) {
                    list.ensureCapacity(bindings.size());
                    for (String key : bindings.keySet()) {
                        list.add(key);
                    }
                }
            }
        }
View Full Code Here


        return engine;
    }

    private ScriptContext getContext(Map<String, Object> bindings) {
        final ScriptContext result = new SimpleScriptContext();
        final Bindings engineScope = result.getBindings(ScriptContext.ENGINE_SCOPE);
        engineScope.putAll(bindings);
        return result;
    }
View Full Code Here

                    System.err.println("Engine supports Invocable interface.");
                }
                System.err.println();
                return;
            }
            Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
            bindings.put("args", args);

            Reader in;
            if (inFileName != null) {
                in = new FileReader(inFileName);
            } else {
View Full Code Here

        Object scriptXML = engine.eval("<a><b>petra</b></a>");
        assertTrue(scriptXML instanceof XMLObject);

        OMElement om = xmlHelper.toOMElement(scriptXML);

        Bindings bindings = engine.createBindings();
        bindings.put("xml", xmlHelper.toScriptXML(om));

        assertEquals("xml", engine.eval("typeof xml", bindings));
        assertEquals("petra", engine.eval("xml.b.toString()", bindings));
    }
View Full Code Here

    public void testE4X() throws ScriptException, XMLStreamException, FactoryConfigurationError {
        Object o = xmlHelper.toScriptXML(createOMElement("<a><b>petra</b></a>"));
        OMElement om = xmlHelper.toOMElement(o);
        assertEquals("<a><b>petra</b></a>", om.toString());

        Bindings bindings = engine.createBindings();
        bindings.put("o", o);
        Object x = engine.eval("typeof o", bindings);
        assertEquals("xml", x);
    }
View Full Code Here

        XMLHelper convertor = XMLHelper.getArgHelper(engine);
        Object o = convertor.toScriptXML(createOMElement("<a><b>petra</b></a>"));
        OMElement om = convertor.toOMElement(o);
        assertEquals("<a><b>petra</b></a>", om.toString());

        Bindings bindings = engine.createBindings();
        bindings.put("o", o);
        Object x = engine.eval("typeof o", bindings);
        assertEquals("xml", x);
    }
View Full Code Here

    public BXMLSerializer() {
        xmlInputFactory = XMLInputFactory.newInstance();
        xmlInputFactory.setProperty("javax.xml.stream.isCoalescing", true);

        scriptEngineManager = new javax.script.ScriptEngineManager();
        scriptEngineManager.setBindings(new Bindings() {
            @Override
            public Object get(Object key) {
                return namespace.get(key.toString());
            }
View Full Code Here

        public Object invoke(Object proxy, Method method, Object[] args)
            throws Throwable {
            Object result = null;

            String methodName = method.getName();
            Bindings bindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
            if (bindings.containsKey(methodName)) {
                Invocable invocable;
                try {
                    invocable = (Invocable)scriptEngine;
                } catch (ClassCastException exception) {
                    throw new SerializationException(exception);
View Full Code Here

        }

        @Override
        public Object evaluate(final Object value) {
            Object result = value;
            Bindings bindings = scriptEngine.getBindings(ScriptContext.GLOBAL_SCOPE);
            if (bindings.containsKey(functionName)) {
                Invocable invocable;
                try {
                    invocable = (Invocable)scriptEngine;
                } catch (ClassCastException exception) {
                    throw new RuntimeException(exception);
View Full Code Here

                ts.setName(tcId);
                ts.execute(false);
                TestResult testResult = ts.getTestResults().get(0);
                testResult.setName(tcId);
                testResult.setComment("");
                Bindings globalContext = JythonTestScript.getEngine().getBindings(ScriptContext.ENGINE_SCOPE);
                if (globalContext.containsKey("result")) {
                    Object returnObject = globalContext.get("result");
                    String returnValue = "None";
                    if (returnObject != null) {
                        returnValue = returnObject.toString();
                    }
                    if (!ts.getTestDataSet().getData().isEmpty()) {
View Full Code Here

TOP

Related Classes of javax.script.Bindings

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.