use of org.apache.jena.graph.Node in project jena by apache.
the class QueryTest method convertToStrings.
private ResultSetRewindable convertToStrings(ResultSetRewindable resultsActual) {
List<Binding> bindings = new ArrayList<>();
while (resultsActual.hasNext()) {
Binding b = resultsActual.nextBinding();
BindingMap b2 = BindingFactory.create();
for (String vn : resultsActual.getResultVars()) {
Var v = Var.alloc(vn);
Node n = b.get(v);
String s;
if (n == null)
s = "";
else if (n.isBlank())
s = "_:" + n.getBlankNodeLabel();
else
s = NodeFunctions.str(n);
b2.add(v, NodeFactory.createLiteral(s));
}
bindings.add(b2);
}
ResultSet rs = new ResultSetStream(resultsActual.getResultVars(), null, new QueryIterPlainWrapper(bindings.iterator()));
return ResultSetFactory.makeRewindable(rs);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class TestGraphUnionRead method gr_union_05.
@Test
public void gr_union_05() {
List<Node> gnodes = list();
Graph g = new GraphUnionRead(dsg, gnodes);
long x = Iter.count(g.find(null, null, null));
assertEquals(0, x);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class TestGraphUnionRead method gr_union_02.
@Test
public void gr_union_02() {
List<Node> gnodes = list(gn1, gn2);
Graph g = new GraphUnionRead(dsg, gnodes);
Node s = NodeFactory.createURI("http://example/s");
long x = Iter.count(g.find(s, null, null));
assertEquals(3, x);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class LabelToNodeMap method asNode.
public Node asNode(String label) {
Node n = bNodeLabels.get(label);
if (n != null)
return n;
n = allocNode();
bNodeLabels.put(label, n);
return n;
}
use of org.apache.jena.graph.Node in project jena by apache.
the class ParserBase method createNode.
protected Node createNode(String iri) {
// Is it a bNode label? i.e. <_:xyz>
if (isBNodeIRI(iri)) {
String s = iri.substring(bNodeLabelStart.length());
Node n = NodeFactory.createBlankNode(s);
return n;
}
return NodeFactory.createURI(iri);
}
Aggregations