Interface RdfGraph

  • All Known Implementing Classes:
    OrderedTripleSet, TripleSet

    public interface RdfGraph
    Represents an RDF graph, a collection of RDF triples.

    An RDF graph is a set of triples, where each triple consists of a subject, predicate, and object, forming a statement of knowledge in the RDF format.

    This interface defines the basic operations on an RDF graph, including checking for the presence of a triple, adding and removing triples (although these operations are unsupported by default), and streaming over the graph's triples.

    • Method Detail

      • contains

        boolean contains​(RdfTriple triple)
        Checks if the RDF graph contains the specified triple.

        This method allows you to verify whether a specific RDF triple is present in the graph.

        Parameters:
        triple - the RdfTriple to check for
        Returns:
        true if the graph contains the specified triple; false otherwise
      • stream

        java.util.stream.Stream<RdfTriple> stream()
        Returns a stream of all the triples in the RDF graph.

        This method provides a convenient way to iterate over all the triples in the graph. It can be used with Java Streams API to process the triples in a functional manner.

        Returns:
        a Stream of RdfTriples representing the RDF graph
      • add

        default boolean add​(RdfTriple triple)
        Adds a triple to the RDF graph.

        This operation is unsupported by default and will throw an UnsupportedOperationException. Implementations that support modification of the graph should override this method.

        Parameters:
        triple - the RdfTriple to add
        Returns:
        true if the triple was successfully added (implementation dependent)
        Throws:
        java.lang.UnsupportedOperationException - if modification of the graph is not supported
      • remove

        default boolean remove​(RdfTriple triple)
        Removes a triple from the RDF graph.

        This operation is unsupported by default and will throw an UnsupportedOperationException. Implementations that support removal of triples should override this method.

        Parameters:
        triple - the RdfTriple to remove
        Returns:
        true if the triple was successfully removed (implementation dependent)
        Throws:
        java.lang.UnsupportedOperationException - if removal of the triple is not supported