Interface RdfDataset

  • All Known Implementing Classes:
    GraphDataset, OrderedQuadDataset, QuadDataset

    public interface RdfDataset
    Represents 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 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 RdfGraph representing the default graph; never null
      • 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 Set of RdfResource graph 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 Optional is returned.

        Parameters:
        graphName - the RdfResource identifying the named graph
        Returns:
        an Optional containing the RdfGraph if present; otherwise, Optional.empty()
        Throws:
        java.lang.NullPointerException - if graphName is null
      • 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 - the RdfGraph to be set as the new default graph
        Returns:
        the updated RdfDataset instance
        Throws:
        java.lang.UnsupportedOperationException - if modification is not supported
        java.lang.NullPointerException - if graph is null
      • namedGraph

        default RdfDataset namedGraph​(RdfResource graphName,
                                      RdfGraph graph)
        Adds or replaces a named graph in the dataset.

        Associates the specified RdfGraph with the given RdfResource graph 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 - the RdfResource identifying the named graph
        graph - the RdfGraph to associate with the specified name
        Returns:
        the updated RdfDataset instance
        Throws:
        java.lang.UnsupportedOperationException - if modification is not supported
        java.lang.NullPointerException - if graphName or graph is null