Package org.openntf.formula

Examples of org.openntf.formula.ASTNode.solve()


      // benchmark the evaluate with a document as context

      try {
        time = System.nanoTime();
        FormulaContext ctx1 = Formulas.createContext(ntfDoc, Formulas.getParser());
        ntfDocResult = ast.solve(ctx1);
        docEvaluateTime += System.nanoTime() - time;
      } catch (Exception e) {
        System.out.println(NTF("Doc-Evaluate failed: ") + ERROR(e));
        e.printStackTrace();
        i = count;
View Full Code Here


      }
      try {
        // benchmark the evaluate with a map as context
        time = System.nanoTime();
        FormulaContext ctx2 = Formulas.createContext(ntfMap, Formulas.getParser());
        ntfMapResult = ast.solve(ctx2);
        mapEvaluateTime += System.nanoTime() - time;
      } catch (Exception e) {
        System.out.println(NTF("Map-Evaluate failed: ") + ERROR(e));
        e.printStackTrace();
        i = count;
View Full Code Here

      // benchmark the evaluate with a document as context

      try {
        time = System.nanoTime();
        FormulaContext ctx1 = Formulas.createContext(ntfDoc, Formulas.getParser());
        ntfDocResult = ast.solve(ctx1);
        docEvaluateTime += System.nanoTime() - time;
      } catch (Exception e) {
        System.out.println(NTF("Doc-Evaluate failed: ") + ERROR(e));
        e.printStackTrace();
        i = count;
View Full Code Here

      }
      try {
        // benchmark the evaluate with a map as context
        time = System.nanoTime();
        FormulaContext ctx2 = Formulas.createContext(ntfMap, Formulas.getParser());
        ntfMapResult = ast.solve(ctx2);
        mapEvaluateTime += System.nanoTime() - time;
      } catch (Exception e) {
        System.out.println(NTF("Map-Evaluate failed: ") + ERROR(e));
        e.printStackTrace();
        i = count;
View Full Code Here

    if (!parserFailed) {
      if (testDoc) {
        try {
          FormulaContext ctx1 = Formulas.createContext(ntfDoc, parser);
          ntfDocResult = ast.solve(ctx1);
        } catch (EvaluateException e) {
          errors.append(NTF("\tDoc-Evaluate failed: ") + ERROR(e) + "\n");
          ntfError = e;
          parserFailed = true;
        } catch (Throwable t) {
View Full Code Here

      }
      if (testMap) {
        try {
          // benchmark the evaluate with a map as context
          FormulaContext ctx2 = Formulas.createContext(ntfMap, parser);
          ntfMapResult = ast.solve(ctx2);
        } catch (EvaluateException e) {
          errors.append(NTF("\tMap-Evaluate failed: ") + ERROR(e) + "\n");
          ntfError = e;
          parserFailed = true;
        } catch (Throwable t) {
View Full Code Here

    if (!parserFailed) {
      try {
        // benchmark the evaluate with a map as context
        FormulaContext ctx2 = Formulas.createContext(ntfMap, parser);
        ntfMapResult = ast.solve(ctx2);
      } catch (EvaluateException e) {
        errors.append(NTF("\tMap-Evaluate failed: ") + ERROR(e) + "\n");
        ntfError = e;
        parserFailed = true;
      } catch (Throwable t) {
View Full Code Here

      public String get(final String key) {
        return args[Integer.valueOf(key)];
      }
    });

    List<Object> ret = x.solve(ctx);
    System.out.println(ret);
  }
}
View Full Code Here

      String passedFormula = (String) ExtLibUtil.getViewScope().get("javaFormula");
      ASTNode ast = null;

      ast = Formulas.getParser().parse(passedFormula);
      FormulaContext ctx1 = Formulas.createContext(null, Formulas.getParser());
      List<Object> result = ast.solve(ctx1);
      ExtLibUtil.getViewScope().put("javaTest", result);
    } catch (Throwable t) {
      XspOpenLogUtil.logError(t);
    }
  }
View Full Code Here

      //n.dump("");

      time = System.currentTimeMillis();
      for (int i = 1; i < 10000; i++) {
        FormulaContext ctx = Formulas.createContext(null, parser);
        v = n.solve(ctx);
      }
      time = System.currentTimeMillis() - time;
      System.err.println("[FormulaEngine] 10000x evaluating AST tree\ttook " + time + "ms.");

      System.out.println("Result:\t" + v);
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.