Examples of ScriptEvaluator


Examples of org.jmol.script.ScriptEvaluator

    selectionManager.addListener(listener);
  }

  BitSet getAtomBitSet(ScriptEvaluator eval, Object atomExpression) {
    if (eval == null)
      eval = new ScriptEvaluator(this);
    return ScriptEvaluator.getAtomBitSet(eval, atomExpression);
  }
View Full Code Here

Examples of org.jmol.script.ScriptEvaluator

  private Object scriptCheck(String strScript, boolean returnContext) {
    // from ConsoleTextPane.checkCommand() and applet Jmol.scriptProcessor()
    if (strScript.indexOf(")") == 0 || strScript.indexOf("!") == 0) // history
      // disabled
      strScript = strScript.substring(1);
    ScriptContext sc = (new ScriptEvaluator(this)).checkScriptSilent(strScript);
    if (returnContext || sc.errorMessage == null)
      return sc;
    return sc.errorMessage;
  }
View Full Code Here

Examples of org.kitesdk.morphline.scriptengine.java.ScriptEvaluator

    ;
  }
 
  @Test
  public void testBasic() throws Exception {
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "return x * 2; ", Integer.class, new String[] { "x" }, new Class[] { Integer.class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Integer(1) });
    assertEquals(result, new Integer(2));
  }
View Full Code Here

Examples of org.kitesdk.morphline.scriptengine.java.ScriptEvaluator

    assertEquals(result, new Integer(2));
  }

  @Test
  public void testVoid() throws Exception {
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "int foo = 0; ", Void.class, new String[] { "x" }, new Class[] { Integer.class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Integer(1) });
    assertNull(result);
  }
View Full Code Here

Examples of org.kitesdk.morphline.scriptengine.java.ScriptEvaluator

    assertNull(result);
  }

  @Test
  public void testArray() throws Exception {
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "return x; ", Integer[].class, new String[] { "x" }, new Class[] { Integer[].class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Integer[] { new Integer(1) }});
    assertEquals(((Integer[]) result)[0], new Integer(1));
  }
View Full Code Here

Examples of org.kitesdk.morphline.scriptengine.java.ScriptEvaluator

  }

  @Test
  public void testExternalObject() throws Exception {
    ArrayListMultimap.create();
    ScriptEvaluator script = new ScriptEvaluator(
        javaImports,
        "com.google.common.collect.ArrayListMultimap.create(); new org.kitesdk.morphline.api.Record(); return x.copy(); ",
        Record.class, new String[] { "x" }, new Class[] { Record.class }, "myQuery");
    Object result = script.evaluate(new Object[] { new Record() });
    assertEquals(result, new Record());
    assertTrue(result != new Record());
  }
View Full Code Here

Examples of org.kitesdk.morphline.scriptengine.java.ScriptEvaluator

  @Test
  public void testBenchmark() throws Exception {
//    long runs = 3000000000L;
//    long runs = 1000000000;
    long runs = 1000000;
    ScriptEvaluator script = new ScriptEvaluator(javaImports, "return x; ", Integer.class, new String[] { "x" }, new Class[] { Integer.class }, "myQuery");
    long start = System.currentTimeMillis();
    int checksum = 0;
    for (long i = 0; i < runs; i++) {
      Object result = script.evaluate(new Integer(1));
//      Integer result = (Integer) script.evaluate(new Integer(1));
//      Integer result = new Long(i).intValue();
      checksum += (result != null ? 1 : 0);
//      checksum += result;
    }
View Full Code Here

Examples of org.springframework.scripting.ScriptEvaluator

*/
public class ScriptTest {

    @Test
    public void test() throws ExecutionException, InterruptedException {
        ScriptEvaluator scriptEvaluator = new GroovyScriptEvaluator();

        //ResourceScriptSource 外部的
        ScriptSource source = new StaticScriptSource("i+j");
        Map<String, Object> args = new HashMap<>();
        args.put("i", 1);
        args.put("j", 2);
        System.out.println(scriptEvaluator.evaluate(source, args));
    }
View Full Code Here

Examples of org.springframework.scripting.ScriptEvaluator

*/
public class GroovyScriptEvaluatorTests {

  @Test
  public void testGroovyScriptFromString() {
    ScriptEvaluator evaluator = new GroovyScriptEvaluator();
    Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2"));
    assertEquals(6, result);
  }
View Full Code Here

Examples of org.springframework.scripting.ScriptEvaluator

    assertEquals(6, result);
  }

  @Test
  public void testGroovyScriptFromFile() {
    ScriptEvaluator evaluator = new GroovyScriptEvaluator();
    Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
    assertEquals(6, result);
  }
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.