Interface RdfDataset
-
- All Known Implementing Classes:
GraphDataset,OrderedQuadDataset,QuadDataset
public interface RdfDatasetRepresents an RDF Dataset.An RDF Dataset is a collection of RDF graphs. It includes:
- A single default graph (unnamed graph)
- Zero or more named graphs, each identified by an IRI or a blank node
This interface provides access to the default graph, the collection of named graph identifiers, and allows retrieval of specific named graphs by their names.
Implementations may or may not support modifications to the dataset.
- See Also:
- RDF 1.1
Dataset,
RdfGraph
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description RdfGraphdefaultGraph()Returns the default graph of the dataset.default RdfDatasetdefaultGraph(RdfGraph graph)Replaces the default graph in the dataset with the specified graph.java.util.Set<RdfResource>graphNames()Returns the set of graph names for all named graphs in the dataset.java.util.Optional<RdfGraph>namedGraph(RdfResource graphName)Returns the named graph corresponding to the provided graph name.default RdfDatasetnamedGraph(RdfResource graphName, RdfGraph graph)Adds or replaces a named graph in the dataset.
-
-
-
Method Detail
-
defaultGraph
RdfGraph defaultGraph()
Returns the default graph of the dataset.The default graph is the unnamed graph in the dataset. It contains RDF triples that are not part of any named graph.
- Returns:
- the
RdfGraphrepresenting the default graph; nevernull
-
graphNames
java.util.Set<RdfResource> graphNames()
Returns the set of graph names for all named graphs in the dataset.Each name is represented as a
RdfResource, which can be an IRI or a blank node identifier.- Returns:
- an immutable
SetofRdfResourcegraph names; empty if no named graphs are present.
-
namedGraph
java.util.Optional<RdfGraph> namedGraph(RdfResource graphName)
Returns the named graph corresponding to the provided graph name.If the dataset does not contain a named graph with the specified name, an empty
Optionalis returned.- Parameters:
graphName- theRdfResourceidentifying the named graph- Returns:
- an
Optionalcontaining theRdfGraphif present; otherwise,Optional.empty() - Throws:
java.lang.NullPointerException- ifgraphNameisnull
-
defaultGraph
default RdfDataset defaultGraph(RdfGraph graph)
Replaces the default graph in the dataset with the specified graph.By default, this operation is unsupported and throws an
UnsupportedOperationException. Implementations that support modification of the dataset should override this method.- Parameters:
graph- theRdfGraphto be set as the new default graph- Returns:
- the updated
RdfDatasetinstance - Throws:
java.lang.UnsupportedOperationException- if modification is not supportedjava.lang.NullPointerException- ifgraphisnull
-
namedGraph
default RdfDataset namedGraph(RdfResource graphName, RdfGraph graph)
Adds or replaces a named graph in the dataset.Associates the specified
RdfGraphwith the givenRdfResourcegraph name. If a graph with the same name already exists, it will be replaced.By default, this operation is unsupported and throws an
UnsupportedOperationException. Implementations that support modification of the dataset should override this method.- Parameters:
graphName- theRdfResourceidentifying the named graphgraph- theRdfGraphto associate with the specified name- Returns:
- the updated
RdfDatasetinstance - Throws:
java.lang.UnsupportedOperationException- if modification is not supportedjava.lang.NullPointerException- ifgraphNameorgraphisnull
-
-