Class DatasetImpl
- java.lang.Object
-
- org.apache.commons.rdf.simple.DatasetImpl
-
-
Field Summary
Fields Modifier and Type Field Description private SimpleRDF
factory
private java.util.Set<Quad>
quads
private static int
TO_STRING_MAX
-
Constructor Summary
Constructors Constructor Description DatasetImpl(SimpleRDF simpleRDF)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Add a quad to the dataset, possibly mapping any of the components to those supported by this dataset.void
add(Quad quad)
Add a quad to the dataset, possibly mapping any of the components of the Quad to those supported by this dataset.void
clear()
Clear the dataset, removing all quads.void
close()
Close the dataset, relinquishing any underlying resources.boolean
contains(java.util.Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Check if dataset contains a pattern of quads.boolean
contains(Quad quad)
Check if dataset contains quad.Graph
getGraph()
Get the default graph of this dataset.java.util.Optional<Graph>
getGraph(BlankNodeOrIRI graphName)
Get a named graph in this dataset.java.util.stream.Stream<BlankNodeOrIRI>
getGraphNames()
Get the graph names in this Dataset.private java.util.stream.Stream<Quad>
getQuads(java.util.function.Predicate<Quad> filter)
private <T extends RDFTerm>
RDFTerminternallyMap(T object)
void
remove(java.util.Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Remove a concrete pattern of quads from the default graph of the dataset.void
remove(Quad quad)
Remove a concrete quad from the dataset.long
size()
Number of quads contained by the dataset.java.util.stream.Stream<Quad>
stream()
Get all quads contained by the dataset.java.util.stream.Stream<Quad>
stream(java.util.Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Get all quads contained by the dataset matched with the pattern.java.lang.String
toString()
-
-
-
Field Detail
-
TO_STRING_MAX
private static final int TO_STRING_MAX
- See Also:
- Constant Field Values
-
quads
private final java.util.Set<Quad> quads
-
factory
private final SimpleRDF factory
-
-
Constructor Detail
-
DatasetImpl
DatasetImpl(SimpleRDF simpleRDF)
-
-
Method Detail
-
add
public void add(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:Dataset
Add a quad to the dataset, possibly mapping any of the components to those supported by this dataset.
-
add
public void add(Quad quad)
Description copied from interface:Dataset
Add a quad to the dataset, possibly mapping any of the components of the Quad to those supported by this dataset.
-
clear
public void clear()
Description copied from interface:Dataset
Clear the dataset, removing all quads.
-
contains
public boolean contains(java.util.Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:Dataset
Check if dataset contains a pattern of quads.- Specified by:
contains
in interfaceDataset
- Parameters:
graphName
- The graph the quad belongs to, wrapped as anOptional
(null
is a wildcard,Optional.empty()
is the default graph)subject
- The quad subject (null
is a wildcard)predicate
- The quad predicate (null
is a wildcard)object
- The quad object (null
is a wildcard)- Returns:
- True if the dataset contains any quads that match the given pattern.
-
contains
public boolean contains(Quad quad)
Description copied from interface:Dataset
Check if dataset contains quad.
-
stream
public java.util.stream.Stream<Quad> stream()
Description copied from interface:Dataset
Get all quads contained by the dataset.
The iteration does not contain any duplicate quads, as determined by the
Quad.equals(Object)
method for eachQuad
.The behaviour of the
Stream
is not specified ifDataset.add(Quad)
,Dataset.remove(Quad)
orDataset.clear()
are called on theDataset
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<Quad> stream(java.util.Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:Dataset
Get all quads contained by the dataset matched with the pattern.The iteration does not contain any duplicate quads, as determined by the
Quad.equals(Object)
method for eachQuad
.The behaviour of the
Stream
is not specified ifDataset.add(Quad)
,Dataset.remove(Quad)
orDataset.clear()
are called on theDataset
before it terminates.Implementations may throw
ConcurrentModificationException
from Stream methods if they detect a conflict while the Stream is active.- Specified by:
stream
in interfaceDataset
- Parameters:
graphName
- The graph the quad belongs to, wrapped as anOptional
(null
is a wildcard,Optional.empty()
is the default graph)subject
- The quad subject (null
is a wildcard)predicate
- The quad predicate (null
is a wildcard)object
- The quad object (null
is a wildcard)- Returns:
- A
Stream
over the matched quads.
-
remove
public void remove(java.util.Optional<BlankNodeOrIRI> graphName, BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
Description copied from interface:Dataset
Remove a concrete pattern of quads from the default graph of the dataset.- Specified by:
remove
in interfaceDataset
- Parameters:
graphName
- The graph the quad belongs to, wrapped as anOptional
(null
is a wildcard,Optional.empty()
is the default graph)subject
- The quad subject (null
is a wildcard)predicate
- The quad predicate (null
is a wildcard)object
- The quad object (null
is a wildcard)
-
remove
public void remove(Quad quad)
Description copied from interface:Dataset
Remove a concrete quad from the dataset.
-
size
public long size()
Description copied from interface:Dataset
Number of quads contained by the dataset.The count of a set does not include duplicates, consistent with the
Quad.equals(Object)
equals method for eachQuad
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
close
public void close()
Description copied from interface:Dataset
Close the dataset, relinquishing any underlying resources.For example, this would close any open file and network streams and free database locks held by the dataset implementation.
The behaviour of the other dataset methods are undefined after closing the dataset.
Implementations might not need
Dataset.close()
, hence the default implementation does nothing.
-
getGraph
public Graph getGraph()
Description copied from interface:Dataset
Get the default graph of this dataset.The
Triple
s of the default graph are equivalent to theQuad
s in this Dataset which has theQuad.getGraphName()
set toOptional.empty()
.It is unspecified if modifications to the returned Graph are reflected in this Dataset.
The returned graph MAY be empty.
- Specified by:
getGraph
in interfaceDataset
- Returns:
- The default graph of this Dataset
- See Also:
Dataset.getGraph(BlankNodeOrIRI)
-
getGraph
public java.util.Optional<Graph> getGraph(BlankNodeOrIRI graphName)
Description copied from interface:Dataset
Get a named graph in this dataset.The
Triple
s of the named graph are equivalent to the the Quads of this Dataset which has theQuad.getGraphName()
equal to the providedgraphName
, or equal toOptional.empty()
if the providedgraphName
isnull
.It is unspecified if modifications to the returned Graph are reflected in this Dataset.
It is unspecified if requesting an unknown or empty graph will return
Optional.empty()
or create a new emptyGraph
.- Specified by:
getGraph
in interfaceDataset
- Parameters:
graphName
- The name of the graph, ornull
for the default graph.- Returns:
- The named Graph, or
Optional.empty()
if the dataset do not contain the named graph. - See Also:
Dataset.getGraph()
,Dataset.getGraphNames()
-
getGraphNames
public java.util.stream.Stream<BlankNodeOrIRI> getGraphNames()
Description copied from interface:Dataset
Get the graph names in this Dataset.The set of returned graph names is equivalent to the set of unique
Quad.getGraphName()
of all theDataset.stream()
of this dataset (excluding the default graph).The returned
Stream
SHOULD NOT contain duplicate graph names.The graph names can be used with
Dataset.getGraph(BlankNodeOrIRI)
to retrieve the correspondingGraph
, however callers should be aware of any concurrent modifications to the Dataset may cause such calls to returnOptional.empty()
.Note that a Dataset always contains a default graph which is not named, and thus is not represented in the returned Stream. The default graph is accessible via
Dataset.getGraph()
or by usingOptional.empty()
in the Quad access methods).- Specified by:
getGraphNames
in interfaceDataset
- Returns:
- A
Stream
of the graph names of this Dataset.
-
-