Search in sources :

Example 1 with Node

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);
    }
}
Also used : Node(org.apache.jena.graph.Node) NodeId(org.apache.jena.tdb.store.NodeId) Pair(org.apache.jena.atlas.lib.Pair)

Example 2 with Node

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;
}
Also used : Var(org.apache.jena.sparql.core.Var) Node(org.apache.jena.graph.Node)

Example 3 with Node

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);
}
Also used : Node(org.apache.jena.graph.Node)

Example 4 with Node

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);
}
Also used : Node(org.apache.jena.graph.Node)

Example 5 with Node

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;
}
Also used : Triple(org.apache.jena.graph.Triple) Node(org.apache.jena.graph.Node) TriplePath(org.apache.jena.sparql.core.TriplePath)

Aggregations

Node (org.apache.jena.graph.Node)1263 Test (org.junit.Test)440 Triple (org.apache.jena.graph.Triple)204 Var (org.apache.jena.sparql.core.Var)165 Graph (org.apache.jena.graph.Graph)125 ArrayList (java.util.ArrayList)105 Binding (org.apache.jena.sparql.engine.binding.Binding)80 Quad (org.apache.jena.sparql.core.Quad)76 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)64 RDFNode (org.apache.jena.rdf.model.RDFNode)64 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)63 Literal (org.apache.jena.rdf.model.Literal)61 PropFuncArg (org.apache.jena.sparql.pfunction.PropFuncArg)56 SpatialArguments (org.apache.jena.geosparql.spatial.property_functions.SpatialArguments)51 SearchEnvelope (org.apache.jena.geosparql.spatial.SearchEnvelope)46 HashMap (java.util.HashMap)45 TriplePath (org.apache.jena.sparql.core.TriplePath)36 Model (org.apache.jena.rdf.model.Model)33 NodeValue (org.apache.jena.sparql.expr.NodeValue)31 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)30