예제 #1
0
  private List<Var> calcVars() {
    List<Var> vars = new ArrayList<>(4);
    // Only if not in parent.
    // A (var/value) binding may have been copied down to record it's NodeId.

    Binding b = idBinding.getParentBinding();

    Iterator<Var> iter = idBinding.iterator();
    for (Var v : idBinding) {
      if (b == null || !b.contains(v)) vars.add(v);
    }
    return vars;
  }
예제 #2
0
 @Override
 protected void format(StringBuffer sbuff, Var var) {
   NodeId id = idBinding.get(var);
   String extra = "";
   if (id != null) extra = "/" + id;
   Node node = get(var);
   String tmp = NodeFmtLib.displayStr(node);
   sbuff.append("( ?" + var.getVarName() + extra + " = " + tmp + " )");
 }
예제 #3
0
  public NodeId getNodeId(Var var) {
    NodeId id = idBinding.get(var);
    if (id != null) return id;

    if (parent == null) return null;

    // Maybe in the parent.
    if (parent instanceof BindingTDB) return ((BindingTDB) parent).getNodeId(var);
    return null;
  }
예제 #4
0
  @Override
  public Node get1(Var var) {
    try {
      Node n = cacheGet(var);
      if (n != null) return n;

      NodeId id = idBinding.get(var);
      if (id == null) return null;
      n = nodeTable.getNodeForNodeId(id);
      // Update cache.
      cachePut(var, n);
      return n;
    } catch (Exception ex) {
      Log.fatal(this, String.format("get1(%s)", var), ex);
      return null;
    }
  }
예제 #5
0
 @Override
 public boolean contains1(Var var) {
   return idBinding.containsKey(var);
 }
예제 #6
0
 @Override
 protected int size1() {
   return idBinding.size();
 }
예제 #7
0
 public BindingTDB(BindingNodeId idBinding, NodeTable nodeTable) {
   // BindingNodeId contains the bindings actually used  copied down when created.
   super(idBinding.getParentBinding());
   this.idBinding = idBinding;
   this.nodeTable = nodeTable;
 }