java.lang.Object
org.apache.jena.graph.GraphUtil
An ad-hoc collection of useful code for graphs
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
static void
static void
Add triples into the destination (arg 1) from the source (arg 2)static boolean
containsNode
(Graph graph, Node node) Does the graph use the node anywhere as a subject, predicate or object?static void
static void
static void
static void
deleteFrom
(Graph dstGraph, Graph srcGraph) Delete triples in the destination (arg 1) as given in the source (arg 2).static void
deleteLoopDst
(Graph dstGraph, Graph srcGraph) Delete the triple insrcGraph
fromdstGraph
by checking the contents ofdsgGraph
against thesrcGraph
.static void
deleteLoopSrc
(Graph dstGraph, Graph srcGraph) Delete triples insrcGraph
fromdstGraph
by looping onsrcGraph
.static ExtendedIterator<Triple>
Answer an iterator covering all the triples in the specified graph.static ExtendedIterator<Node>
listObjects
(Graph g, Node s, Node p) Return an iterator over the unique objects with a given subject and object.static ExtendedIterator<Node>
listPredicates
(Graph g, Node s, Node o) Return an iterator over the unique predicate between s and o.static ExtendedIterator<Node>
listSubjects
(Graph g, Node p, Node o) Return an iterator over the unique subjects with predicate p and object o.static void
A safe and cautious remove() function that converts the remove to a number ofGraph.delete(Triple)
operations.
-
Method Details
-
listSubjects
Return an iterator over the unique subjects with predicate p and object o. p and o can be wildcards (Node.ANY)- Parameters:
g
- Graphp
- Predicate - may be Node.ANYo
- Object - may be Node.ANY- Returns:
- ExtendedIterator
-
listPredicates
Return an iterator over the unique predicate between s and o. s and o can be wildcards (Node.ANY)- Parameters:
g
- Graphs
- Subject - may be Node.ANYo
- Object - may be Node.ANY- Returns:
- ExtendedIterator
-
listObjects
Return an iterator over the unique objects with a given subject and object. s and p can be wildcards (Node.ANY)- Parameters:
g
- Graphs
- Subject - may be Node.ANYp
- Predicate - may be Node.ANY- Returns:
- ExtendedIterator
-
containsNode
Does the graph use the node anywhere as a subject, predicate or object? -
findAll
Answer an iterator covering all the triples in the specified graph.- Parameters:
g
- the graph from which to extract triples- Returns:
- an iterator over all the graph's triples
-
add
-
add
-
add
-
addInto
Add triples into the destination (arg 1) from the source (arg 2) -
delete
-
delete
-
delete
-
remove
A safe and cautious remove() function that converts the remove to a number ofGraph.delete(Triple)
operations.To avoid any possible ConcurrentModificationExceptions, it finds batches of triples, deletes them and tries again until no more triples matching the input can be found.
-
deleteLoopSrc
Delete triples insrcGraph
fromdstGraph
by looping onsrcGraph
. -
deleteLoopDst
Delete the triple insrcGraph
fromdstGraph
by checking the contents ofdsgGraph
against thesrcGraph
. This involves callingsrcGraph.contains
.- Implementation Note:
dstGraph.size()
is used by this method.
-
deleteFrom
Delete triples in the destination (arg 1) as given in the source (arg 2).- Implementation Note:
- This is designed for the case of
dstGraph
being comparable or much larger thansrcGraph
orsrcGraph
having a lot of triples to actually be deleted fromdstGraph
. This includes the case of large, persistentdstGraph
.It is not designed for a large
srcGraph
and largedstGraph
with only a few triples in common to delete fromdstGraph
. It is better to calculate the difference in some way, and copy into a small graph to use as thesrcGraph
.To force delete by looping on
srcGraph
, usedeleteLoopSrc(Graph, Graph)
.For large
srcGraph
and smalldstGraph
, usedeleteLoopDst(org.apache.jena.graph.Graph, org.apache.jena.graph.Graph)
. See discussion on jena/pull/212, (archived at JENA-1284).
-