Package javax.script

Examples of javax.script.CompiledScript.eval()


        String inlineScript = cl.getOptionValue(script.getOpt());
        try {
          if (engine instanceof Compilable) {
            Compilable compiledEng = (Compilable) engine;
            CompiledScript script = compiledEng.compile(inlineScript);
            script.eval(ctx);
            if (invoke) {
              this.invokeFunctionOrMethod(shellState, engine, cl, argArray);
            }
          } else {
            engine.eval(inlineScript, ctx);
View Full Code Here


        {
          engine.setContext(context);
          if(Config.SCRIPT_CACHE)
          {
            CompiledScript cs = _cache.loadCompiledScript(engine, file);
            cs.eval(context);
          }
          else
          {
            Compilable eng = (Compilable) engine;
            CompiledScript cs = eng.compile(lnr);
View Full Code Here

          }
          else
          {
            Compilable eng = (Compilable) engine;
            CompiledScript cs = eng.compile(lnr);
            cs.eval(context);
          }
        }
        finally
        {
          engine.setContext(ctx);
View Full Code Here

  {
    if(engine instanceof Compilable && Config.SCRIPT_ALLOW_COMPILATION)
    {
      Compilable eng = (Compilable) engine;
      CompiledScript cs = eng.compile(script);
      return context != null ? cs.eval(context) : cs.eval();
    }
    return context != null ? engine.eval(script, context) : engine.eval(script);
  }

  public Object eval(String engineName, String script) throws ScriptException
View Full Code Here

  {
    if(engine instanceof Compilable && Config.SCRIPT_ALLOW_COMPILATION)
    {
      Compilable eng = (Compilable) engine;
      CompiledScript cs = eng.compile(script);
      return context != null ? cs.eval(context) : cs.eval();
    }
    return context != null ? engine.eval(script, context) : engine.eval(script);
  }

  public Object eval(String engineName, String script) throws ScriptException
View Full Code Here

            Bindings bindings = engine.createBindings();
            bindings.put("invokers", invokersCopy);
            bindings.put("invocation", invocation);
            bindings.put("context", RpcContext.getContext());
            CompiledScript function = compilable.compile(rule);
            Object obj = function.eval(bindings);
            if (obj instanceof Invoker[]) {
                invokersCopy = Arrays.asList((Invoker<T>[]) obj);
            } else if (obj instanceof Object[]) {
                invokersCopy = new ArrayList<Invoker<T>>();
                for (Object inv : (Object[]) obj) {
View Full Code Here

    public void testCompileEvalString() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");

        CompiledScript five = ((Compilable) pythonEngine).compile("5");
        assertEquals(Integer.valueOf(5), five.eval());
    }

    public void testEvalReader() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");
View Full Code Here

    public void testCompileEvalReader() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");

        CompiledScript five = ((Compilable) pythonEngine).compile(new StringReader("5"));
        assertEquals(Integer.valueOf(5), five.eval());
    }

    public void testBindings() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");
View Full Code Here

      fail(buildMessage("RhinoScriptEngine.compileScript(): Unexpected " +
          "ScriptException ..", ex.getMessage()));
    }
   
    try {
      script.eval();
      String str = getOutput();
      assertEquals("PASSED", str);
    } catch (ScriptException ex) {
      fail(buildMessage("RhinoScriptEngine.compileScript(): Unexpected " +
          "ScriptException ..", ex.getMessage()));
View Full Code Here

            Bindings bindings = engine.createBindings();
            bindings.put("invokers", invokersCopy);
            bindings.put("invocation", invocation);
            bindings.put("context", RpcContext.getContext());
            CompiledScript function = compilable.compile(rule);
            Object obj = function.eval(bindings);
            if (obj instanceof Invoker[]) {
                invokersCopy = Arrays.asList((Invoker<T>[]) obj);
            } else if (obj instanceof Object[]) {
                invokersCopy = new ArrayList<Invoker<T>>();
                for (Object inv : (Object[]) 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.