use of org.apache.jena.graph.Triple in project jena by apache.
the class GraphSPARQLService method graphBaseFind.
// @Override
// public Capabilities getCapabilities()
// {
// if (capabilities == null)
// capabilities = new AllCapabilities()
// { @Override public boolean handlesLiteralTyping() { return false; } };
// return capabilities;
// }
@Override
protected ExtendedIterator<Triple> graphBaseFind(Triple m) {
Node s = m.getMatchSubject();
Var sVar = null;
if (s == null) {
sVar = Var.alloc("s");
s = sVar;
}
Node p = m.getMatchPredicate();
Var pVar = null;
if (p == null) {
pVar = Var.alloc("p");
p = pVar;
}
Node o = m.getMatchObject();
Var oVar = null;
if (o == null) {
oVar = Var.alloc("o");
o = oVar;
}
Triple triple = new Triple(s, p, o);
// Evaluate as an algebra expression
BasicPattern pattern = new BasicPattern();
pattern.add(triple);
Op op = new OpBGP(pattern);
// return WrappedIterator.createNoRemove(triples.iterator()) ;
return null;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class NodeTransformLib method transform.
/** Do a node->node conversion of a BGP - return original BGP for "no change" */
public static BasicPattern transform(NodeTransform nodeTransform, BasicPattern pattern) {
BasicPattern bgp2 = new BasicPattern();
boolean changed = false;
for (Triple triple : pattern) {
Triple t2 = transform(nodeTransform, triple);
bgp2.add(t2);
if (t2 != triple)
changed = true;
}
if (!changed)
return pattern;
return bgp2;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class ElementTransformSubst method transform.
@Override
public Element transform(ElementTriplesBlock el) {
ElementTriplesBlock etb = new ElementTriplesBlock();
boolean changed = false;
for (Triple t : el.getPattern()) {
Triple t2 = transform(t);
changed = changed || t != t2;
etb.addTriple(t2);
}
if (changed)
return etb;
return el;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class FmtUtils method formatPattern.
public static void formatPattern(IndentedWriter out, BasicPattern pattern, SerializationContext sCxt) {
StringBuilder buffer = new StringBuilder();
boolean first = true;
for (Triple triple : pattern) {
if (!first)
buffer.append("\n");
stringForTriple(buffer, triple, sCxt);
buffer.append(" .");
out.print(buffer.toString());
buffer.setLength(0);
first = false;
}
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class IsoMatcher method tuplesTriples.
private static List<Tuple<Node>> tuplesTriples(Iterator<Triple> iter) {
List<Tuple<Node>> tuples = new ArrayList<>();
for (; iter.hasNext(); ) {
Triple t = iter.next();
Tuple<Node> tuple = tuple(t.getSubject(), t.getPredicate(), t.getObject());
tuples.add(tuple);
}
return tuples;
}
Aggregations