public static Expr substitute(Expr expr, Binding binding) { if ( isNotNeeded(binding) ) return expr; return expr.copySubstitute(binding); }
public static ExprList substitute(ExprList exprList, Binding binding) { if ( isNotNeeded(binding) ) return exprList; return exprList.copySubstitute(binding); }
public static Op substitute(Op op, Binding binding) { // Want to avoid cost if the binding is empty // but the empty test is not zero-cost on non-empty things. if ( isNotNeeded(binding) ) return op; return Transformer.transform(new OpSubstituteWorker(binding), op); }
public static BasicPattern substitute(BasicPattern bgp, Binding binding) { if ( isNotNeeded(binding) ) return bgp; BasicPattern bgp2 = new BasicPattern(); for ( Triple triple : bgp ) { Triple t = substitute(triple, binding); bgp2.add(t); } return bgp2; }
public static PropFuncArg substitute(PropFuncArg propFuncArg, Binding binding) { if ( isNotNeeded(binding) ) return propFuncArg; if ( propFuncArg.isNode() ) { Node n = propFuncArg.getArg(); if ( !Var.isVar(n) ) // Not a Var, no substitute needed. return propFuncArg; return new PropFuncArg(substitute(propFuncArg.getArg(), binding)); } List<Node> newArgList = new ArrayList<>(); for ( Node n : propFuncArg.getArgList() ) newArgList.add(substitute(n, binding)); return new PropFuncArg(newArgList); }
public static Triple substitute(Triple triple, Binding binding) { if ( isNotNeeded(binding) ) return triple; Node s = triple.getSubject(); Node p = triple.getPredicate(); Node o = triple.getObject(); Node s1 = substitute(s, binding); Node p1 = substitute(p, binding); Node o1 = substitute(o, binding); Triple t = triple; if ( s1 != s || p1 != p || o1 != o ) t = new Triple(s1, p1, o1); return t; }
public static Quad substitute(Quad quad, Binding binding) { if ( isNotNeeded(binding) ) return quad; Node g = quad.getGraph(); Node s = quad.getSubject(); Node p = quad.getPredicate(); Node o = quad.getObject(); Node g1 = substitute(g, binding); Node s1 = substitute(s, binding); Node p1 = substitute(p, binding); Node o1 = substitute(o, binding); Quad q = quad; if ( s1 != s || p1 != p || o1 != o || g1 != g ) q = new Quad(g1, s1, p1, o1); return q; }