public class DatasetGraphView extends Object implements Graph
Graph
view on a Dataset
.
This view is backed by a Dataset
, and can be constructed in two ways:
DatasetGraphView(Dataset)
Quad
s of the Dataset is represented as a Triple
. Adding
triples will add them to the default graph, while removing triples
will remove from all graphs.DatasetGraphView(Dataset, BlankNodeOrIRI)
IRI
,
a BlankNode
, or null
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.
Constructor and Description |
---|
DatasetGraphView(Dataset dataset) |
DatasetGraphView(Dataset dataset,
BlankNodeOrIRI namedGraph) |
Modifier and Type | Method and 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.
|
Stream<? extends Triple> |
stream()
Gets all triples contained by the graph.
|
Stream<? extends Triple> |
stream(BlankNodeOrIRI subject,
IRI predicate,
RDFTerm object)
Gets all triples contained by the graph matched with the pattern.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTriples, getTriples, iterate, iterate
public DatasetGraphView(Dataset dataset)
public DatasetGraphView(Dataset dataset, BlankNodeOrIRI namedGraph)
public void close() throws Exception
Graph
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.
close
in interface AutoCloseable
close
in interface Graph
Exception
public void add(Triple triple)
Graph
public void add(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Graph
public boolean contains(Triple triple)
Graph
public boolean contains(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Graph
public void remove(Triple triple)
Graph
public void remove(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Graph
public void clear()
Graph
public long size()
Graph
The count of a set does not include duplicates, consistent with the
Triple.equals(Object)
equals method for each Triple
.
public Stream<? extends Triple> stream()
Graph
The iteration does not contain any duplicate triples, as determined by
the Triple.equals(Object)
method for each Triple
.
The behaviour of the Stream
is not specified if
Graph.add(Triple)
, Graph.remove(Triple)
or Graph.clear()
are
called on the Graph
before it terminates.
Implementations may throw ConcurrentModificationException
from
Stream methods if they detect a conflict while the Stream is active.
public Stream<? extends Triple> stream(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Graph
The iteration does not contain any duplicate triples, as determined by
the Triple.equals(Object)
method for each Triple
.
The behaviour of the Stream
is not specified if
Graph.add(Triple)
, Graph.remove(Triple)
or Graph.clear()
are
called on the Graph
before it terminates.
Implementations may throw ConcurrentModificationException
from
Stream methods if they detect a conflict while the Stream is active.
Copyright © 2015–2018 The Apache Software Foundation. All rights reserved.