java.lang.Object
org.apache.jena.graph.GraphUtil
An ad-hoc collection of useful code for graphs
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidstatic voidstatic voidAdd triples into the destination (arg 1) from the source (arg 2)static booleancontainsNode(Graph graph, Node node) Does the graph use the node anywhere as a subject, predicate or object?static voidstatic voidstatic voidstatic voiddeleteFrom(Graph dstGraph, Graph srcGraph) Delete triples in the destination (arg 1) as given in the source (arg 2).static voiddeleteLoopDst(Graph dstGraph, Graph srcGraph) Delete the triple insrcGraphfromdstGraphby checking the contents ofdsgGraphagainst thesrcGraph.static voiddeleteLoopSrc(Graph dstGraph, Graph srcGraph) Delete triples insrcGraphfromdstGraphby 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 voidA 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 insrcGraphfromdstGraphby looping onsrcGraph. -
deleteLoopDst
Delete the triple insrcGraphfromdstGraphby checking the contents ofdsgGraphagainst 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
dstGraphbeing comparable or much larger thansrcGraphorsrcGraphhaving a lot of triples to actually be deleted fromdstGraph. This includes the case of large, persistentdstGraph.It is not designed for a large
srcGraphand largedstGraphwith 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
srcGraphand smalldstGraph, usedeleteLoopDst(org.apache.jena.graph.Graph, org.apache.jena.graph.Graph). See discussion on jena/pull/212, (archived at JENA-1284).
-