Example #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;
  }
Example #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;
   }
 }
Example #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();
  }
Example #4
0
 @Override
 public NodeValue exec(NodeValue v) {
   return NodeValue.makeDouble(1d / v.getDouble());
 }
Example #5
0
 @Override
 protected NodeValue evalSpecial(Binding binding, FunctionEnv env) {
   return NodeValue.booleanReturn(checkAccess(binding));
 }
Example #6
0
 @Override
 public NodeValue exec(NodeValue v) {
   return NodeValue.makeDouble(Math.atan(v.getDouble()));
 }
Example #7
0
 public static Expr nodeToExpr(Node n) {
   if (n.isVariable()) return new ExprVar(n);
   return NodeValue.makeNode(n);
 }
Example #8
0
 public static NodeValue parseNodeValue(String s) {
   Node n = NodeFactoryExtra.parseNode(s);
   NodeValue nv = NodeValue.makeNode(n);
   return nv;
 }