Class DatasetGraphView
- All Implemented Interfaces:
AutoCloseable
,Graph
,GraphLike<Triple>
Graph
view on a Dataset
.
This view is backed by a Dataset
, and can be constructed in two ways:
DatasetGraphView(Dataset)
- Expose a union graph view of the Dataset, where all the
Quad
s of the Dataset is represented as aTriple
. Adding triples will add them to the default graph, while removing triples will remove from all graphs. DatasetGraphView(Dataset, BlankNodeOrIRI)
- Expose a particular graph of the Dataset, either named by an
IRI
, aBlankNode
, ornull
for the default graph.
Changes in the Graph are reflected directly in the Dataset and vice versa. This class is thread-safe is the underlying Dataset is thread-safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Dataset
private final BlankNodeOrIRI
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionDatasetGraphView
(Dataset dataset) DatasetGraphView
(Dataset dataset, BlankNodeOrIRI namedGraph) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) Adds a triple to the graph, possibly mapping any of the components to those supported by this Graph.void
Adds a triple to the graph, possibly mapping any of the components of the Triple to those supported by this Graph.void
clear()
Clears the graph, removing all triples.void
close()
Closes the graph, relinquishing any underlying resources.boolean
contains
(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) Checks if graph contains a pattern of triples.boolean
Checks if graph contains triple.void
remove
(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) Removes a concrete pattern of triples from the graph.void
Removes a concrete triple from the graph.long
size()
Number of triples contained by the graph.stream()
Gets all triples contained by the graph.stream
(BlankNodeOrIRI subject, IRI predicate, RDFTerm object) Gets all triples contained by the graph matched with the pattern.private Optional
<BlankNodeOrIRI> Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.rdf.api.Graph
getTriples, getTriples, iterate, iterate
-
Field Details
-
unionGraph
private final boolean unionGraph -
namedGraph
-
dataset
-
-
Constructor Details
-
DatasetGraphView
-
DatasetGraphView
-
-
Method Details
-
close
Description copied from interface:Graph
Closes the graph, relinquishing any underlying resources.For example, this would close any open file and network streams and free database locks held by the Graph implementation.
The behaviour of the other Graph methods are undefined after closing the graph.
Implementations might not need
Graph.close()
, hence the default implementation does nothing.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceGraph
- Throws:
Exception
-
add
Description copied from interface:Graph
Adds a triple to the graph, possibly mapping any of the components of the Triple to those supported by this Graph. -
add
Description copied from interface:Graph
Adds a triple to the graph, possibly mapping any of the components to those supported by this Graph. -
contains
Description copied from interface:Graph
Checks if graph contains triple. -
unionOrNamedGraph
-
contains
Description copied from interface:Graph
Checks if graph contains a pattern of triples. -
remove
Description copied from interface:Graph
Removes a concrete triple from the graph. -
remove
Description copied from interface:Graph
Removes a concrete pattern of triples from the graph. -
clear
public void clear()Description copied from interface:Graph
Clears the graph, removing all triples. -
size
public long size()Description copied from interface:Graph
Number of triples contained by the graph.The count of a set does not include duplicates, consistent with the
Triple.equals(Object)
equals method for eachTriple
. -
stream
Description copied from interface:Graph
Gets all triples contained by the graph.
The iteration does not contain any duplicate triples, as determined by the
Triple.equals(Object)
method for eachTriple
.The behaviour of the
Stream
is not specified ifGraph.add(Triple)
,Graph.remove(Triple)
orGraph.clear()
are called on theGraph
before it terminates.Implementations may throw
ConcurrentModificationException
from Stream methods if they detect a conflict while the Stream is active. -
stream
Description copied from interface:Graph
Gets all triples contained by the graph matched with the pattern.The iteration does not contain any duplicate triples, as determined by the
Triple.equals(Object)
method for eachTriple
.The behaviour of the
Stream
is not specified ifGraph.add(Triple)
,Graph.remove(Triple)
orGraph.clear()
are called on theGraph
before it terminates.Implementations may throw
ConcurrentModificationException
from Stream methods if they detect a conflict while the Stream is active.
-