Class DatasetGraphView
- java.lang.Object
-
- org.apache.commons.rdf.simple.DatasetGraphView
-
public class DatasetGraphView extends java.lang.Object implements Graph
AGraphview 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
Quads 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, ornullfor 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 Datasetdatasetprivate BlankNodeOrIRInamedGraphprivate booleanunionGraph
-
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 voidadd(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)Adds a triple to the graph, possibly mapping any of the components to those supported by this Graph.voidadd(Triple triple)Adds a triple to the graph, possibly mapping any of the components of the Triple to those supported by this Graph.voidclear()Clears the graph, removing all triples.voidclose()Closes the graph, relinquishing any underlying resources.booleancontains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)Checks if graph contains a pattern of triples.booleancontains(Triple triple)Checks if graph contains triple.voidremove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)Removes a concrete pattern of triples from the graph.voidremove(Triple triple)Removes a concrete triple from the graph.longsize()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.ExceptionDescription copied from interface:GraphCloses 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:GraphAdds 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:GraphAdds 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:GraphChecks 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:GraphChecks if graph contains a pattern of triples.
-
remove
public void remove(Triple triple)
Description copied from interface:GraphRemoves a concrete triple from the graph.
-
remove
public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:GraphRemoves a concrete pattern of triples from the graph.
-
clear
public void clear()
Description copied from interface:GraphClears the graph, removing all triples.
-
size
public long size()
Description copied from interface:GraphNumber 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:GraphGets 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
Streamis not specified ifGraph.add(Triple),Graph.remove(Triple)orGraph.clear()are called on theGraphbefore it terminates.Implementations may throw
ConcurrentModificationExceptionfrom 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:GraphGets 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
Streamis not specified ifGraph.add(Triple),Graph.remove(Triple)orGraph.clear()are called on theGraphbefore it terminates.Implementations may throw
ConcurrentModificationExceptionfrom Stream methods if they detect a conflict while the Stream is active.
-
-