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; }
@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 + " )"); }
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; }
@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; } }
@Override public boolean contains1(Var var) { return idBinding.containsKey(var); }
@Override protected int size1() { return idBinding.size(); }
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; }