Class DatasetGraphView
- java.lang.Object
-
- org.apache.commons.rdf.simple.DatasetGraphView
-
public class DatasetGraphView extends java.lang.Object implements Graph
AGraph
view on aDataset
.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
Fields Modifier and Type Field Description private Dataset
dataset
private BlankNodeOrIRI
namedGraph
private boolean
unionGraph
-
Constructor Summary
Constructors Constructor Description DatasetGraphView(Dataset dataset)
DatasetGraphView(Dataset dataset, BlankNodeOrIRI namedGraph)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
add(Triple triple)
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
contains(Triple triple)
Checks if graph contains triple.void
remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Removes a concrete pattern of triples from the graph.void
remove(Triple triple)
Removes a concrete triple from the graph.long
size()
Number of triples contained by the graph.java.util.stream.Stream<? extends Triple>
stream()
Gets all triples contained by the graph.java.util.stream.Stream<? extends Triple>
stream(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Gets all triples contained by the graph matched with the pattern.private java.util.Optional<BlankNodeOrIRI>
unionOrNamedGraph()
-
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 Detail
-
unionGraph
private final boolean unionGraph
-
namedGraph
private final BlankNodeOrIRI namedGraph
-
dataset
private final Dataset dataset
-
-
Constructor Detail
-
DatasetGraphView
public DatasetGraphView(Dataset dataset)
-
DatasetGraphView
public DatasetGraphView(Dataset dataset, BlankNodeOrIRI namedGraph)
-
-
Method Detail
-
close
public void close() throws java.lang.Exception
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.
-
add
public void add(Triple triple)
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
public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:Graph
Adds a triple to the graph, possibly mapping any of the components to those supported by this Graph.
-
contains
public boolean contains(Triple triple)
Description copied from interface:Graph
Checks if graph contains triple.
-
unionOrNamedGraph
private java.util.Optional<BlankNodeOrIRI> unionOrNamedGraph()
-
contains
public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:Graph
Checks if graph contains a pattern of triples.
-
remove
public void remove(Triple triple)
Description copied from interface:Graph
Removes a concrete triple from the graph.
-
remove
public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
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
public java.util.stream.Stream<? extends Triple> 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
public java.util.stream.Stream<? extends Triple> stream(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
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.
-
-