Package javax.script

Examples of javax.script.CompiledScript.eval()


        String expResult = "A rolling stone gathers no moss.";
        assertEquals(expResult, result);
        result = (String) cs.eval();
        expResult = "A friend in need is a friend indeed.";
        assertEquals(expResult, result);
        result = (String) cs.eval();
        expResult = "Every garden may have some weeds.";
        assertEquals(expResult, result);
       
        instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
        instance = null;
View Full Code Here


        {
            try
            {
                Bindings binding = new SimpleBindings();
                binding.put("args", args);
                result = script.eval(binding);
            }
            catch(ScriptException ex)
            {
                logger_.warn(LogUtil.throwableToString(ex));
            }
View Full Code Here

                                            ((Compilable) scriptEngine).compile(fileReader);
                                    compiledScriptsCache.put(cacheKey, compiledScript);
                                }
                            }
                        }
                        return compiledScript.eval(bindings);
                    } else {
                        // TODO Charset ?
                        fileReader = new BufferedReader(new FileReader(scriptFile),
                                (int)scriptFile.length());
                        return scriptEngine.eval(fileReader, bindings);                   
View Full Code Here

                                    ((Compilable) scriptEngine).compile(getScript());
                            compiledScriptsCache.put(cacheKey, compiledScript);
                        }
                    }
                }
                return compiledScript.eval(bindings);
            } else {
                return scriptEngine.eval(getScript(), bindings);
            }
        } else {
            throw new ScriptException("Both script file and script text are empty for element:"+getName());           
View Full Code Here

        try {
            final CompiledScript script = this.engine.compile(annotation.value());
            final Bindings bindings = getBindings(method, arguments);
            bindings.put(IT, vertex);
            bindings.put(G, framedGraph);
            final Object result = script.eval(bindings);

            // TODO: Deprecate the use of _() and replace with it
            if (result instanceof Pipe & annotation.value().startsWith(PIPE)) {
                LOGGER.warning("_() is deprecated in favor of using 'it' to represent the framed vertex");
                ((Pipe) result).setStarts(new SingleIterator<Element>(vertex));
View Full Code Here

    final Bindings binding = scriptManager.bind(compiledScript.getEngine().getBindings(ScriptContext.ENGINE_SCOPE),
        (ODatabaseRecordTx) db, iContext, iArgs);

    try {
      final Object ob = compiledScript.eval(binding);

      return OCommandExecutorUtility.transformResult(ob);
    } catch (ScriptException e) {
      throw new OCommandScriptException("Error on execution of the script", request.getText(), e.getColumnNumber(), e);
View Full Code Here

                    String name = names.get(random.nextInt(names.size() - 1));
                    try {
                        final Bindings bindings = engine.createBindings();
                        bindings.put("g", TinkerGraphFactory.createTinkerGraph());
                        bindings.put("name", name);
                        Object result = script.eval(bindings);
                        if (name.equals("stephen") || name.equals("pavel") || name.equals("matthias"))
                            assertNull(result);
                        else
                            assertNotNull(result);
                    } catch (ScriptException e) {
View Full Code Here

        long totalTime = 0l;
        for (int i = 0; i < runs; i++) {
            long time = System.currentTimeMillis();
            CompiledScript script = engine.compile("g.v(1).out().count()");
            script.eval(bindings);
            totalTime += System.currentTimeMillis() - time;
        }
        System.out.println("Multi-compiled script runtime for " + runs + " runs: " + totalTime);

        totalTime = 0l;
View Full Code Here

        totalTime = 0l;
        CompiledScript script = engine.compile("g.v(1).out().count()");
        for (int i = 0; i < runs; i++) {
            long time = System.currentTimeMillis();
            script.eval(bindings);
            totalTime += System.currentTimeMillis() - time;
        }
        System.out.println("Compiled script runtime for " + runs + " runs: " + totalTime);
    }
View Full Code Here

      assertEquals("value",se.eval("key"));
      if (se instanceof Compilable){
          Compilable co = (Compilable) se;
          CompiledScript cs = co.compile("key");
          assertNotNull(cs);
          assertEquals("value",cs.eval());
            assertEquals("value",cs.eval());         
      } else {
          fail("Expected engine to implement Compilable");
      }
  }
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.