Search in sources :

Example 1 with GraphWithPerform

use of org.apache.jena.graph.impl.GraphWithPerform in project jena by apache.

the class GraphUtil method deleteIteratorWorkerDirect.

/**
     * Delete the triples supplied by an iterator. This function is not "concurrent
     * modification" safe; it assumes it can use the iterator while deleting from the
     * graph.
     */
private static void deleteIteratorWorkerDirect(Graph graph, Iterator<Triple> it) {
    if (OldStyle && graph instanceof GraphWithPerform) {
        GraphWithPerform g = (GraphWithPerform) graph;
        it.forEachRemaining(g::performDelete);
    } else {
        it.forEachRemaining(graph::delete);
    }
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform)

Example 2 with GraphWithPerform

use of org.apache.jena.graph.impl.GraphWithPerform in project jena by apache.

the class GraphUtil method delete.

public static void delete(Graph graph, Triple[] triples) {
    if (OldStyle && graph instanceof GraphWithPerform) {
        GraphWithPerform g = (GraphWithPerform) graph;
        for (Triple t : triples) g.performDelete(t);
        graph.getEventManager().notifyDeleteArray(graph, triples);
    } else {
        for (Triple t : triples) graph.delete(t);
    }
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform)

Example 3 with GraphWithPerform

use of org.apache.jena.graph.impl.GraphWithPerform in project jena by apache.

the class GraphUtil method addIteratorWorkerDirect.

private static void addIteratorWorkerDirect(Graph graph, Iterator<Triple> it) {
    if (OldStyle && graph instanceof GraphWithPerform) {
        GraphWithPerform g = (GraphWithPerform) graph;
        it.forEachRemaining(g::performAdd);
    } else {
        it.forEachRemaining(graph::add);
    }
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform)

Example 4 with GraphWithPerform

use of org.apache.jena.graph.impl.GraphWithPerform in project jena by apache.

the class GraphWithPerformContractTest method testPerformAdd_Triple.

@ContractTest
public void testPerformAdd_Triple() {
    GraphWithPerform g = (GraphWithPerform) graphWith(producer.newInstance(), "S P O; S2 P2 O2");
    g.getEventManager().register(GL);
    txnBegin(g);
    g.performAdd(triple("S3 P3 O3"));
    txnCommit(g);
    GL.assertEmpty();
    assertTrue(g.contains(triple("S3 P3 O3")));
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform) ContractTest(org.xenei.junit.contract.ContractTest)

Example 5 with GraphWithPerform

use of org.apache.jena.graph.impl.GraphWithPerform in project jena by apache.

the class GraphWithPerformContractTest method testPerformDelete_Triple.

@ContractTest
public void testPerformDelete_Triple() {
    GraphWithPerform g = (GraphWithPerform) graphWith(producer.newInstance(), "S P O; S2 P2 O2");
    g.getEventManager().register(GL);
    txnBegin(g);
    g.performDelete(triple("S2 P2 O2"));
    txnCommit(g);
    GL.assertEmpty();
    assertFalse(g.contains(triple("S2 P2 O2")));
}
Also used : GraphWithPerform(org.apache.jena.graph.impl.GraphWithPerform) ContractTest(org.xenei.junit.contract.ContractTest)

Aggregations

GraphWithPerform (org.apache.jena.graph.impl.GraphWithPerform)6 ContractTest (org.xenei.junit.contract.ContractTest)2