Interface RDF4JDataset

All Superinterfaces:
AutoCloseable, org.apache.commons.rdf.api.Dataset, org.apache.commons.rdf.api.GraphLike<org.apache.commons.rdf.api.Quad>, RDF4JGraphLike<org.apache.commons.rdf.api.Quad>

public interface RDF4JDataset extends org.apache.commons.rdf.api.Dataset, RDF4JGraphLike<org.apache.commons.rdf.api.Quad>
Marker interface for RDF4J implementations of Dataset.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Stream<org.apache.commons.rdf.api.BlankNodeOrIRI>
    ClosableIterable<org.apache.commons.rdf.api.Quad>
    ClosableIterable<org.apache.commons.rdf.api.Quad>
    iterate(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object)
    stream(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object)

    Methods inherited from interface org.apache.commons.rdf.api.Dataset

    add, add, clear, close, contains, contains, getGraph, getGraph, remove, remove, size

    Methods inherited from interface org.apache.commons.rdfrdf4j.RDF4JGraphLike

    asModel, asRepository
  • Method Details

    • getGraphNames

      Stream<org.apache.commons.rdf.api.BlankNodeOrIRI> getGraphNames()

      Note that for datasets backed by a repository (RDF4JGraphLike.asRepository() is present), the stream must be closed with BaseStream.close().

      This can generally achieved using a try-with-resources block, e.g.:

       int graphs;
       try (Stream<BlankNodeOrIRI> s : graph.stream()) {
         graphs = s.count()
       }
       
      Specified by:
      getGraphNames in interface org.apache.commons.rdf.api.Dataset
    • iterate

      ClosableIterable<org.apache.commons.rdf.api.Quad> iterate()

      Note that for datasets backed by a repository (RDF4JGraphLike.asRepository() is present), the iterable must be closed with AutoCloseable.close().

      This can generally achieved using a try-with-resources block, e.g.:

       try (ClosableIterable<Quad> s : graph.iterate()) {
         for (Quad q : quads) {
             return q; // OK to terminate for-loop early
         }
       }
       
      If you don't use a try-with-resources block, the iterator will attempt to close the ClosableIterable when reaching the end of the iteration.
      Specified by:
      iterate in interface org.apache.commons.rdf.api.Dataset
      Specified by:
      iterate in interface org.apache.commons.rdf.api.GraphLike<org.apache.commons.rdf.api.Quad>
    • iterate

      ClosableIterable<org.apache.commons.rdf.api.Quad> iterate(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object)

      Note that for datasets backed by a repository (RDF4JGraphLike.asRepository() is present), the iterable must be closed with AutoCloseable.close().

      This can generally achieved using a try-with-resources block, e.g.:

       try (ClosableIterable<Quad> s : graph.iterate(g,s,p,o)) {
         for (Quad q : quads) {
             return q; // OK to terminate for-loop early
         }
       }
       
      If you don't use a try-with-resources block, the iterator will attempt to close the ClosableIterable when reaching the end of the iteration.
      Specified by:
      iterate in interface org.apache.commons.rdf.api.Dataset
    • stream

      Stream<RDF4JQuad> stream()

      Note that for datasets backed by a repository (RDF4JGraphLike.asRepository() is present), the stream must be closed with BaseStream.close().

      This can generally achieved using a try-with-resources block, e.g.:

       int subjects;
       try (Stream<RDF4JQuad> s : graph.stream()) {
         subjects = s.map(RDF4JQuad::getSubject).distinct().count()
       }
       
      Specified by:
      stream in interface org.apache.commons.rdf.api.Dataset
      Specified by:
      stream in interface org.apache.commons.rdf.api.GraphLike<org.apache.commons.rdf.api.Quad>
    • stream

      Stream<RDF4JQuad> stream(Optional<org.apache.commons.rdf.api.BlankNodeOrIRI> graphName, org.apache.commons.rdf.api.BlankNodeOrIRI subject, org.apache.commons.rdf.api.IRI predicate, org.apache.commons.rdf.api.RDFTerm object)

      Note that for datasets backed by a repository (RDF4JGraphLike.asRepository() is present), the stream must be closed with BaseStream.close().

      This can generally achieved using a try-with-resources block, e.g.:

       int subjects;
       try (Stream<RDF4JQuad> s : graph.stream()) {
         subjects = s.map(RDF4JQuad::getSubject).distinct().count()
       }
       
      Specified by:
      stream in interface org.apache.commons.rdf.api.Dataset