Package javax.script

Examples of javax.script.ScriptEngine.eval()


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


    }

    @Test
    public void shouldProcessScriptWithUTF8Characters() throws Exception {
        final ScriptEngine engine = new GremlinGroovyScriptEngine();
        assertEquals("轉注", engine.eval("'轉注'"));
    }

    @Test
    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
    public void shouldProcessUTF8Query() throws Exception {
View Full Code Here

            Bindings bindings = engine.getBindings(ENGINE_SCOPE);
            bindings.put("connection", connection);

            try {
                engine.eval(new FileReader(file));
            }
            catch (Exception e) {
                throw new RuntimeException("Error while running " + file, e);
            }
        });
View Full Code Here

                        }

                        BufferedReader scriptReader = null;
                        try {
                            scriptReader = new BufferedReader(new InputStreamReader(scriptLocation.openStream()));
                            scriptEngine.eval(scriptReader);
                        } catch(ScriptException exception) {
                            exception.printStackTrace();
                        } finally {
                            if (scriptReader != null) {
                                scriptReader.close();
View Full Code Here

                    scriptEngine.setBindings(bindings, ScriptContext.ENGINE_SCOPE);

                    String script = (String)element.value;
                    if (script != null) {
                        try {
                            scriptEngine.eval(script);
                        } catch (ScriptException exception) {
                            System.err.println(exception);
                            System.err.println(script);
                        }
                    }
View Full Code Here

        index = definition.getIeProfileGroupIndex().intValue();
      }
     
      Object object = null;
      if (!Format.isNullOrEmpty(definition.getIeProfileFieldValue())) {
        engine.eval(definition.getIeProfileFieldValue());
        object = engine.get("value");
      }
      else {
        String ieProfileMethodName = "";
        if (!isGroup) {
View Full Code Here

      if (definition.getIeProfilePosition() != null) {
        fieldValue = tokens[definition.getIeProfilePosition().intValue() - 1];
      }
      if (!Format.isNullOrEmpty(definition.getIeProfileFieldValue())) {
        try {
          engine.eval(definition.getIeProfileFieldValue());
        }
        catch (javax.script.ScriptException e) {
          String message = "[" + definition.getIeProfileFieldValue() + "] - [" + e.getMessage() + "]";
          throw new ItemCsvTransformationException(message);
        }
View Full Code Here

        binding.put("$" + i, iArgs.get(i));
      }

    try {
      Object result = null;
      result = scriptEngine.eval(script, binding);

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

        binding.put("$" + i, iArgs.get(i));
      }

    try {
      Object result = null;
      result = scriptEngine.eval(script, binding);

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

    public void testEvalAndCompile() throws ScriptException{
        ScriptEngine se = mgr.getEngineByName("JUnit");
        assertNotNull(se);
        se.put("key", "value");
        assertEquals("value",se.eval("key"));
        if (se instanceof Compilable){
            Compilable co = (Compilable) se;
            CompiledScript cs = co.compile("key");
            assertNotNull(cs);
            assertEquals("value",cs.eval());
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.