Examples of invokeFunction()


Examples of javax.script.Invocable.invokeFunction()

             Invocable inv = (Invocable) engine;
             if (req.getDataType()== DataType.MEASUREMENT) {
                 MeasurementDataNumeric res;
                 try {
                     Object ret = inv.invokeFunction("metric",req.getName());
                     if (ret instanceof Number) {
                         Double num = ((Number)ret).doubleValue();
                         res = new MeasurementDataNumeric(req,num);
                         report.addData(res);
                     }
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

                 }
             }
             else if (req.getDataType()==DataType.TRAIT) {
                 MeasurementDataTrait res;
                 try {
                     Object ret = inv.invokeFunction("trait",req.getName());
                     if (ret instanceof String) {
                         String val = ((String)ret);
                         res = new MeasurementDataTrait(req,val);
                         report.addData(res);
                     }
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

        assertTrue(engine instanceof Invocable);
        Invocable invocableScript = (Invocable) engine;

        Object xmlIn = xmlHelper.toScriptXML(createOMElement("<a><b>petra</b></a>"));

        Object o = invocableScript.invokeFunction("isXML", new Object[]{xmlIn});
        assertTrue(o instanceof Boolean);
        assertTrue(((Boolean)o).booleanValue());
    }

    public void testInvokeFunctionOutXML() throws ScriptException, XMLStreamException, FactoryConfigurationError, NoSuchMethodException {
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

        assertTrue(engine instanceof Invocable);
        Invocable invocableScript = (Invocable) engine;

        Object xmlIn = xmlHelper.toScriptXML(createOMElement("<a><b>petra</b></a>"));

        Object xmlOut = invocableScript.invokeFunction("hello", new Object[]{xmlIn});
        OMElement omOut = xmlHelper.toOMElement(xmlOut);
        assertEquals("<foo><b>petra</b></foo>", omOut.toString());
    }

    public void testE4X() throws ScriptException, XMLStreamException, FactoryConfigurationError {
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

        ScriptEngine engine = manager.getEngineByExtension("py");
        assertNotNull("engine should not be null", engine);
        engine.eval("def hello(name):\n return 'Hello ' + name");
        assertTrue("engine should be invocable",engine instanceof Invocable);
        Invocable invocableScript = (Invocable) engine;
        assertEquals("Hello Monty", invocableScript.invokeFunction("hello", new Object[] { "Monty" }));
    }

}
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

                    invocable = (Invocable)scriptEngine;
                } catch (ClassCastException exception) {
                    throw new SerializationException(exception);
                }

                result = invocable.invokeFunction(methodName, args);
            }

            // If the function didn't return a value, return the default
            if (result == null) {
                Class<?> returnType = method.getReturnType();
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

                } catch (ClassCastException exception) {
                    throw new RuntimeException(exception);
                }

                try {
                    result = invocable.invokeFunction(functionName, result);
                } catch (NoSuchMethodException exception) {
                    throw new RuntimeException(exception);
                } catch (ScriptException exception) {
                    throw new RuntimeException(exception);
                }
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

                    invocable = (Invocable)scriptEngine;
                } catch (ClassCastException exception) {
                    throw new SerializationException(exception);
                }

                result = invocable.invokeFunction(methodName, args);
            }

            // If the function didn't return a value, return the default
            if (result == null) {
                Class<?> returnType = method.getReturnType();
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

                } catch (ClassCastException exception) {
                    throw new RuntimeException(exception);
                }

                try {
                    value = invocable.invokeFunction(functionName, value);
                } catch (NoSuchMethodException exception) {
                    throw new RuntimeException(exception);
                } catch (ScriptException exception) {
                    throw new RuntimeException(exception);
                }
View Full Code Here

Examples of javax.script.Invocable.invokeFunction()

      scriptReader = new FileReader("JRubyScripts/test_multifunctions.rb");
      // Evaluate (execute) the script. Once evaluated, any functions
      // in the script can be called with the invokeFunction method.
      rubyEngine.eval(scriptReader);
      // Call function
      obj = rubyInvocableEngine.invokeFunction("function_two",
          "HelloWord");
      // Call method (procedure)
      rubyInvocableEngine.invokeMethod("", "function_one", new Object[0]);
      scriptReader.close();
      System.out.printf("Return of the function '%s'\n", obj);
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.