use of org.apache.jena.sparql.core.Substitute in project jena by apache.
the class SolverRX4 method match.
// RDF term matcher - may recurse and call matchTriple is a triple term is in the pattern.
private static boolean match(BindingBuilder bb, Node nData, Node nPattern) {
if (nPattern == null)
return true;
if (nData == Node.ANY)
return true;
// Deep substitute. This happens anyway as we walk structures.
// nPattern = Substitute.substitute(nPattern, input);
// Shallow substitute
nPattern = Var.lookup(v -> bb.get(v), nPattern);
// nPattern.isConcrete() : either nPattern is an RDF term or is <<>> with no variables.
if (nPattern.isConcrete()) {
// Term comparison.
return sameTermAs(nData, nPattern);
}
// Easy case - nPattern is a variable.
if (Var.isVar(nPattern)) {
Var var = Var.alloc(nPattern);
bb.add(var, nData);
return true;
}
// nPattern is <<>> with variables. Is the data a <<>>?
if (!nData.isNodeTriple())
return false;
// nData is <<>>, nPattern is <<>>
// Unpack, match components.
Triple tPattern = nPattern.getTriple();
Triple tData = nData.getTriple();
return SolverRX3.bindTriple(bb, tData, tPattern);
}
use of org.apache.jena.sparql.core.Substitute in project jena by apache.
the class SolverRX3 method match.
// RDF term matcher - may recurse and call matchTriple is a triple term is in the pattern.
private static boolean match(BindingBuilder bb, Node nData, Node nPattern) {
if (nPattern == null)
return true;
if (nData == Node.ANY)
return true;
// Deep substitute. This happens anyway as we walk structures.
// nPattern = Substitute.substitute(nPattern, input);
// Shallow substitute
nPattern = Var.lookup(v -> bb.get(v), nPattern);
// nPattern.isConcrete() : either nPattern is an RDF term or is <<>> with no variables.
if (nPattern.isConcrete()) {
// Term comparison.
return sameTermAs(nData, nPattern);
}
// Easy case - nPattern is a variable.
if (Var.isVar(nPattern)) {
Var var = Var.alloc(nPattern);
bb.add(var, nData);
return true;
}
// nPattern is <<>> with variables. Is the data a <<>>?
if (!nData.isNodeTriple())
return false;
// nData is <<>>, nPattern is <<>>
// Unpack, match components.
Triple tPattern = nPattern.getTriple();
Triple tData = nData.getTriple();
return bindTriple(bb, tData, tPattern);
}
Aggregations