Esempio n. 1
0
  @Override
  public NodeValue exec(NodeValue v) {
    Node n = v.asNode();
    if (!n.isBlank()) throw new ExprEvalException("bnode: not a blank node");

    NodeValue nv = NodeValue.makeString(n.getBlankNodeId().getLabelString());
    return nv;
  }
Esempio n. 2
0
 public static void evalPrint(Expr expr, Binding binding) {
   try {
     NodeValue r = eval(expr, binding);
     // System.out.println(r.asQuotedString()) ;
     Node n = r.asNode();
     String s = FmtUtils.stringForNode(n);
     System.out.println(s);
   } catch (ExprEvalException ex) {
     System.out.println("Exception: " + ex.getMessage());
     return;
   } catch (ExprBuildException ex) {
     System.err.println("Build exception: " + ex.getMessage());
     return;
   }
 }
Esempio n. 3
0
  public static String joinList(List<Expr> args, String sep) {
    if (args == null) return "<<Null list>>";

    if (args.size() == 0) return "<<Empty list>>";

    StringBuilder s = new StringBuilder();

    boolean first = true;

    for (Expr ex : args) {
      if (!first) s.append(sep);
      // Values are printed withquoting.
      if (ex instanceof NodeValue) {
        NodeValue nv = (NodeValue) ex;
        s.append(nv.asQuotedString());
      } else s.append(ex.toString());
      first = false;
    }
    return s.toString();
  }
Esempio n. 4
0
 @Override
 public NodeValue exec(NodeValue v) {
   return NodeValue.makeDouble(1d / v.getDouble());
 }
Esempio n. 5
0
 @Override
 protected NodeValue evalSpecial(Binding binding, FunctionEnv env) {
   return NodeValue.booleanReturn(checkAccess(binding));
 }
Esempio n. 6
0
 @Override
 public NodeValue exec(NodeValue v) {
   return NodeValue.makeDouble(Math.atan(v.getDouble()));
 }
Esempio n. 7
0
 public static Expr nodeToExpr(Node n) {
   if (n.isVariable()) return new ExprVar(n);
   return NodeValue.makeNode(n);
 }
Esempio n. 8
0
 public static NodeValue parseNodeValue(String s) {
   Node n = NodeFactoryExtra.parseNode(s);
   NodeValue nv = NodeValue.makeNode(n);
   return nv;
 }