RdfDataset class final
Represents an immutable RDF dataset containing a default graph and named graphs
An RDF dataset is formally defined as a collection consisting of:
- Exactly one default graph (which may be empty)
- Zero or more named graphs, each identified by an IRI
This class provides functionality for:
- Creating datasets from graphs
- Accessing graphs by name or as collections
- Checking for graph existence
- Iterating over named graphs
The class follows immutability principles - all instances are read-only and operations that would modify the dataset return new instances.
Implementation Notes
- Named graphs are stored in a Map for O(1) lookup by IRI
- The default graph is always present (empty graph if not specified)
- Graph names must be IRIs as per RDF 1.1 specification
- Duplicate graph names are not allowed (Map ensures uniqueness)
Example:
// Create a dataset with both default and named graphs
final dataset = RdfDataset(
defaultGraph: myDefaultGraph,
namedGraphs: {
IriTerm('http://example.org/graph1'): graph1,
IriTerm('http://example.org/graph2'): graph2,
},
);
// Access graphs
final graph1 = dataset.graph(IriTerm('http://example.org/graph1'));
final allGraphNames = dataset.graphNames;
Constructors
-
RdfDataset.new({required RdfGraph defaultGraph, required Map<
RdfGraphName, RdfGraph> namedGraphs}) - Creates an RDF dataset with the specified default graph and named graphs
- RdfDataset.empty()
- Creates an empty RDF dataset
- RdfDataset.fromDefaultGraph(RdfGraph graph)
- Creates a dataset from a default graph with no named graphs
-
RdfDataset.fromGraphs(List<
RdfNamedGraph> graphs) - Creates a dataset from a list of named graphs with an empty default graph
-
RdfDataset.fromQuads(Iterable<
Quad> quads) - Creates a dataset from a collection of RDF quads
Properties
- defaultGraph → RdfGraph
-
The default graph of this dataset
final
-
graphNames
→ Iterable<
RdfGraphName> -
Get all graph names (IRIs) in this dataset
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
-
namedGraphs
→ Iterable<
RdfNamedGraph> -
Get all named graphs as RdfNamedGraph instances
no setter
-
quads
→ Iterable<
Quad> -
Get all statements in this dataset as quads
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
containsGraph(
RdfGraphName name) → bool - Check if a named graph exists in this dataset
-
graph(
RdfGraphName name) → RdfGraph? - Retrieve a named graph by its IRI identifier
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override