use of org.apache.jena.graph.Node in project jena by apache.
the class NodeTableTrans method append.
/** Copy from the journal file to the real file */
/*package*/
void append() {
Iterator<Pair<NodeId, Node>> iter = nodeTableJournal.all();
Pair<NodeId, Node> firstPair = null;
Pair<NodeId, Node> lastPair = null;
for (; iter.hasNext(); ) {
Pair<NodeId, Node> x = iter.next();
if (firstPair == null)
firstPair = x;
lastPair = x;
NodeId nodeId = x.getLeft();
Node node = x.getRight();
debug(" append: %s -> %s", x, mapFromJournal(nodeId));
// This does the write.
NodeId nodeId2 = base.getAllocateNodeId(node);
if (!nodeId2.equals(mapFromJournal(nodeId)))
inconsistent(node, nodeId, nodeId2);
}
}
use of org.apache.jena.graph.Node in project jena by apache.
the class NodeTransformBNodesToVariables method apply.
@Override
public Node apply(Node node) {
if (!node.isBlank())
return node;
Node node2 = mapping.get(node);
if (node2 == null) {
Var v = varAlloc.allocVar();
mapping.put(node, v);
node2 = v;
}
return node2;
}
use of org.apache.jena.graph.Node in project jena by apache.
the class LibTestExpr method test.
static void test(String exprString, String result) {
Node r = NodeFactoryExtra.parseNode(result);
test(exprString, r);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class GraphMakerContractTest method sameGraph.
/**
* Weak test for "same graph": adding this to one is visible in t'other.
* Stopgap for use in testCanFindCreatedGraph. TODO: clean that test up
* (left over from RDB days)
*/
private boolean sameGraph(Graph g1, Graph g2) {
Node S = GraphHelper.node("S"), P = GraphHelper.node("P"), O = GraphHelper.node("O");
g1.add(Triple.create(S, P, O));
g2.add(Triple.create(O, P, S));
return g2.contains(S, P, O) && g1.contains(O, P, S);
}
use of org.apache.jena.graph.Node in project jena by apache.
the class WhereProcessor method list.
/**
* Create a list node from a list of objects as per RDF Collections.
*
* http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections
*
* @param objs
* the list of objects for the list.
* @return the first blank node in the list.
*/
public Node list(Object... objs) {
Node retval = NodeFactory.createBlankNode();
Node lastObject = retval;
for (int i = 0; i < objs.length; i++) {
Node n = AbstractQueryBuilder.makeNode(objs[i], prefixHandler.getPrefixes());
addWhere(new TriplePath(new Triple(lastObject, RDF.first.asNode(), n)));
if (i + 1 < objs.length) {
Node nextObject = NodeFactory.createBlankNode();
addWhere(new TriplePath(new Triple(lastObject, RDF.rest.asNode(), nextObject)));
lastObject = nextObject;
} else {
addWhere(new TriplePath(new Triple(lastObject, RDF.rest.asNode(), RDF.nil.asNode())));
}
}
return retval;
}
Aggregations