Interface RDFConnection

All Superinterfaces:
AutoCloseable, RDFDatasetAccessConnection, RDFDatasetConnection, SparqlQueryConnection, SparqlUpdateConnection, org.apache.jena.sparql.core.Transactional
All Known Subinterfaces:
RDFConnectionFuseki, RDFConnectionRemote
All Known Implementing Classes:
RDFConnectionAdapter, RDFConnectionFuseki.RDFConnectionFusekiImpl, RDFConnectionLocal, RDFConnectionWrapper

public interface RDFConnection extends SparqlQueryConnection, SparqlUpdateConnection, RDFDatasetConnection, org.apache.jena.sparql.core.Transactional, AutoCloseable
Interface for SPARQL operations on a datasets, whether local or remote. Operations can performed via this interface or via the various interfaces for a subset of the operations. For remote operations, the SPARQL Protocol is used for query and updates and SPARQL Graph Store Protocol for the graph operations and in addition, there are analogous operations on datasets (fetch, load, put; but not delete). RDFConnection provides transaction boundaries. If not in a transaction, an implicit transactional wrapper is applied ("autocommit"). Remote SPARQL operations are atomic but without additional capabilities from the remote server, multiple operations are not combined into a single transaction. Not all implementations may implement all operations. See the implementation notes for details.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.jena.sparql.core.Transactional

    org.apache.jena.sparql.core.Transactional.Promote
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close this connection.
    connect(String serviceURL)
    Create a connection to a remote location by URL.
    connect(org.apache.jena.query.Dataset dataset)
    Connect to a local (same JVM) dataset.
    connect(org.apache.jena.query.Dataset dataset, Isolation isolation)
    Connect to a local (same JVM) dataset.
    connectPW(String URL, String user, String password)
    Make a remote RDFConnection to the URL, with user and password for the client access using basic auth.
    void
    Remove all data from the default graph.
    void
    delete(String graphName)
    Delete a graph from the dataset.
    org.apache.jena.rdf.model.Model
    Fetch the default graph.
    org.apache.jena.rdf.model.Model
    fetch(String graphName)
    Fetch a named graph.
    org.apache.jena.query.Dataset
    Fetch the contents of the dataset
    boolean
    Test whether this connection is closed or not
    void
    load(String file)
    Load (add, append) RDF into the default graph of a dataset.
    void
    load(String graphName, String file)
    Load (add, append) RDF into a named graph in a dataset.
    void
    load(String graphName, org.apache.jena.rdf.model.Model model)
    Load (add, append) RDF into a named graph in a dataset.
    void
    load(org.apache.jena.rdf.model.Model model)
    Load (add, append) RDF into the default graph of a dataset.
    void
     
    void
    loadDataset(org.apache.jena.query.Dataset dataset)
     
    org.apache.jena.query.QueryExecutionBuilder
    Return a execution builder initialized with the RDFConnection setup.
    org.apache.jena.update.UpdateExecutionBuilder
    Return a UpdateExecutionBuilder that is initially configured for this link setup and type.
    void
    put(String file)
    Set the contents of the default graph of a dataset.
    void
    put(String graphName, String file)
    Set the contents of a named graph of a dataset.
    void
    put(String graphName, org.apache.jena.rdf.model.Model model)
    Set the contents of a named graph of a dataset.
    void
    put(org.apache.jena.rdf.model.Model model)
    Set the contents of the default graph of a dataset.
    void
     
    void
    putDataset(org.apache.jena.query.Dataset dataset)
     
    default org.apache.jena.query.QueryExecution
    query(String queryString)
    Setup a SPARQL query execution.
    org.apache.jena.query.QueryExecution
    query(org.apache.jena.query.Query query)
    Setup a SPARQL query execution.
    default boolean
    queryAsk(String queryString)
    Execute a ASK query and return a boolean
    default boolean
    queryAsk(org.apache.jena.query.Query query)
    Execute a ASK query and return a boolean
    queryConnect(String queryServiceURL)
    Create a connection to a remote location for SPARQL query requests
    default org.apache.jena.rdf.model.Model
    queryConstruct(String queryString)
    Execute a CONSTRUCT query and return as a Model
    default org.apache.jena.rdf.model.Model
    queryConstruct(org.apache.jena.query.Query query)
    Execute a CONSTRUCT query and return as a Model
    default org.apache.jena.rdf.model.Model
    queryDescribe(String queryString)
    Execute a DESCRIBE query and return as a Model
    default org.apache.jena.rdf.model.Model
    queryDescribe(org.apache.jena.query.Query query)
    Execute a DESCRIBE query and return as a Model
    default void
    queryResultSet(String queryString, Consumer<org.apache.jena.query.ResultSet> resultSetAction)
    Execute a SELECT query and process the ResultSet with the handler code.
    default void
    queryResultSet(org.apache.jena.query.Query query, Consumer<org.apache.jena.query.ResultSet> resultSetAction)
    Execute a SELECT query and process the ResultSet with the handler code.
    default void
    querySelect(String queryString, Consumer<org.apache.jena.query.QuerySolution> rowAction)
    Execute a SELECT query and process the rows of the results with the handler code.
    default void
    querySelect(org.apache.jena.query.Query query, Consumer<org.apache.jena.query.QuerySolution> rowAction)
    Execute a SELECT query and process the rows of the results with the handler code.
    default void
    update(String updateString)
    Execute a SPARQL Update.
    default void
    update(org.apache.jena.update.Update update)
    Execute a SPARQL Update.
    void
    update(org.apache.jena.update.UpdateRequest update)
    Execute a SPARQL Update.

    Methods inherited from interface org.apache.jena.sparql.core.Transactional

    abort, begin, begin, begin, calc, calculate, calculateRead, calculateWrite, commit, end, exec, execute, executeRead, executeWrite, isInTransaction, promote, promote, transactionMode, transactionType
  • Method Details

    • connect

      static RDFConnection connect(org.apache.jena.query.Dataset dataset)
      Connect to a local (same JVM) dataset. The default isolation is NONE. See connect(Dataset, Isolation) to select an isolation mode.
      Parameters:
      dataset -
      Returns:
      RDFConnection
      See Also:
    • connect

      static RDFConnection connect(org.apache.jena.query.Dataset dataset, Isolation isolation)
      Connect to a local (same JVM) dataset.

      Multiple levels of Isolation are provided, The default COPY level makes a local RDFConnection behave like a remote connection. See the documentation for more details.

      • COPYModels and Datasets are copied. This is most like a remote connection.
      • READONLY – Read-only wrappers are added but changes to the underlying model or dataset will be seen.
      • NONE (default) – Changes to the returned Models or Datasets act on the original object.
      Parameters:
      dataset -
      isolation -
      Returns:
      RDFConnection
    • queryConnect

      static RDFConnection queryConnect(String queryServiceURL)
      Create a connection to a remote location for SPARQL query requests
      Parameters:
      queryServiceURL -
      Returns:
      RDFConnection
    • connect

      static RDFConnection connect(String serviceURL)
      Create a connection to a remote location by URL. This is the URL for the dataset.

      This is the URL for the dataset. Other names can be specified using RDFConnectionRemote.newBuilder() and setting the endpoint URLs.

       RDFConnectionRemote.newBuilder()
             .queryEndpoint(queryServiceEndpoint)
             .updateEndpoint(updateServiceEndpoint)
             .gspEndpoint(graphStoreProtocolEndpoint)
             .build();
       
      Parameters:
      serviceURL -
      Returns:
      RDFConnection
    • connectPW

      static RDFConnection connectPW(String URL, String user, String password)
      Make a remote RDFConnection to the URL, with user and password for the client access using basic auth. Use with care – basic auth over plain HTTP reveals the password on the network.
      Parameters:
      URL -
      user -
      password -
      Returns:
      RDFConnection
    • queryResultSet

      default void queryResultSet(String queryString, Consumer<org.apache.jena.query.ResultSet> resultSetAction)
      Execute a SELECT query and process the ResultSet with the handler code.
      Specified by:
      queryResultSet in interface SparqlQueryConnection
      Parameters:
      queryString -
      resultSetAction -
    • queryResultSet

      default void queryResultSet(org.apache.jena.query.Query query, Consumer<org.apache.jena.query.ResultSet> resultSetAction)
      Execute a SELECT query and process the ResultSet with the handler code.
      Specified by:
      queryResultSet in interface SparqlQueryConnection
      Parameters:
      query -
      resultSetAction -
    • querySelect

      default void querySelect(String queryString, Consumer<org.apache.jena.query.QuerySolution> rowAction)
      Execute a SELECT query and process the rows of the results with the handler code.
      Specified by:
      querySelect in interface SparqlQueryConnection
      Parameters:
      queryString -
      rowAction -
    • querySelect

      default void querySelect(org.apache.jena.query.Query query, Consumer<org.apache.jena.query.QuerySolution> rowAction)
      Execute a SELECT query and process the rows of the results with the handler code.
      Specified by:
      querySelect in interface SparqlQueryConnection
      Parameters:
      query -
      rowAction -
    • queryConstruct

      default org.apache.jena.rdf.model.Model queryConstruct(String queryString)
      Execute a CONSTRUCT query and return as a Model
      Specified by:
      queryConstruct in interface SparqlQueryConnection
    • queryConstruct

      default org.apache.jena.rdf.model.Model queryConstruct(org.apache.jena.query.Query query)
      Execute a CONSTRUCT query and return as a Model
      Specified by:
      queryConstruct in interface SparqlQueryConnection
    • queryDescribe

      default org.apache.jena.rdf.model.Model queryDescribe(String queryString)
      Execute a DESCRIBE query and return as a Model
      Specified by:
      queryDescribe in interface SparqlQueryConnection
    • queryDescribe

      default org.apache.jena.rdf.model.Model queryDescribe(org.apache.jena.query.Query query)
      Execute a DESCRIBE query and return as a Model
      Specified by:
      queryDescribe in interface SparqlQueryConnection
    • queryAsk

      default boolean queryAsk(String queryString)
      Execute a ASK query and return a boolean
      Specified by:
      queryAsk in interface SparqlQueryConnection
    • queryAsk

      default boolean queryAsk(org.apache.jena.query.Query query)
      Execute a ASK query and return a boolean
      Specified by:
      queryAsk in interface SparqlQueryConnection
    • query

      org.apache.jena.query.QueryExecution query(org.apache.jena.query.Query query)
      Setup a SPARQL query execution. See also querySelect(Query, Consumer), queryConstruct(Query), queryDescribe(Query), queryAsk(Query) for ways to execute queries for of a specific form.
      Specified by:
      query in interface SparqlQueryConnection
      Parameters:
      query -
      Returns:
      QueryExecution
    • query

      default org.apache.jena.query.QueryExecution query(String queryString)
      Setup a SPARQL query execution. This is a low-level operation. Handling the QueryExecution should be done with try-resource. Some QueryExecutions, such as ones connecting to a remote server, need to be properly closed to release system resources. See also querySelect(String, Consumer), queryConstruct(String), queryDescribe(String), queryAsk(String) for ways to execute queries of a specific form.
      Specified by:
      query in interface SparqlQueryConnection
      Parameters:
      queryString -
      Returns:
      QueryExecution
    • newQuery

      org.apache.jena.query.QueryExecutionBuilder newQuery()
      Return a execution builder initialized with the RDFConnection setup.
      Specified by:
      newQuery in interface SparqlQueryConnection
      Returns:
      QueryExecutionBuilderCommon
    • update

      default void update(org.apache.jena.update.Update update)
      Execute a SPARQL Update.
      Specified by:
      update in interface SparqlUpdateConnection
      Parameters:
      update -
    • update

      void update(org.apache.jena.update.UpdateRequest update)
      Execute a SPARQL Update.
      Specified by:
      update in interface SparqlUpdateConnection
      Parameters:
      update -
    • update

      default void update(String updateString)
      Execute a SPARQL Update.
      Specified by:
      update in interface SparqlUpdateConnection
      Parameters:
      updateString -
    • newUpdate

      org.apache.jena.update.UpdateExecutionBuilder newUpdate()
      Return a UpdateExecutionBuilder that is initially configured for this link setup and type. The update built will be set to go to the same dataset/remote endpoint as the other RDFLink operations.
      Specified by:
      newUpdate in interface SparqlUpdateConnection
      Returns:
      UpdateExecBuilder
    • fetch

      org.apache.jena.rdf.model.Model fetch(String graphName)
      Fetch a named graph. This is SPARQL Graph Store Protocol HTTP GET or equivalent.
      Specified by:
      fetch in interface RDFDatasetAccessConnection
      Parameters:
      graphName - URI string for the graph name (null or "default" for the default graph)
      Returns:
      Model
    • fetch

      org.apache.jena.rdf.model.Model fetch()
      Fetch the default graph. This is SPARQL Graph Store Protocol HTTP GET or equivalent.
      Specified by:
      fetch in interface RDFDatasetAccessConnection
      Returns:
      Model
    • fetchDataset

      org.apache.jena.query.Dataset fetchDataset()
      Fetch the contents of the dataset
      Specified by:
      fetchDataset in interface RDFDatasetAccessConnection
    • load

      void load(String graphName, String file)
      Load (add, append) RDF into a named graph in a dataset. This is SPARQL Graph Store Protocol HTTP POST or equivalent.
      Specified by:
      load in interface RDFDatasetConnection
      Parameters:
      graphName - Graph name (null or "default" for the default graph)
      file - File of the data.
    • load

      void load(String file)
      Load (add, append) RDF into the default graph of a dataset. This is SPARQL Graph Store Protocol HTTP POST or equivalent.
      Specified by:
      load in interface RDFDatasetConnection
      Parameters:
      file - File of the data.
    • load

      void load(String graphName, org.apache.jena.rdf.model.Model model)
      Load (add, append) RDF into a named graph in a dataset. This is SPARQL Graph Store Protocol HTTP POST or equivalent.
      Specified by:
      load in interface RDFDatasetConnection
      Parameters:
      graphName - Graph name (null or "default" for the default graph)
      model - Data.
    • load

      void load(org.apache.jena.rdf.model.Model model)
      Load (add, append) RDF into the default graph of a dataset. This is SPARQL Graph Store Protocol HTTP POST or equivalent.
      Specified by:
      load in interface RDFDatasetConnection
      Parameters:
      model - Data.
    • put

      void put(String graphName, String file)
      Set the contents of a named graph of a dataset. Any existing data is lost. This is SPARQL Graph Store Protocol HTTP PUT or equivalent.
      Specified by:
      put in interface RDFDatasetConnection
      Parameters:
      graphName - Graph name (null or "default" for the default graph)
      file - File of the data.
    • put

      void put(String file)
      Set the contents of the default graph of a dataset. Any existing data is lost. This is SPARQL Graph Store Protocol HTTP PUT or equivalent.
      Specified by:
      put in interface RDFDatasetConnection
      Parameters:
      file - File of the data.
    • put

      void put(String graphName, org.apache.jena.rdf.model.Model model)
      Set the contents of a named graph of a dataset. Any existing data is lost. This is SPARQL Graph Store Protocol HTTP PUT or equivalent.
      Specified by:
      put in interface RDFDatasetConnection
      Parameters:
      graphName - Graph name (null or "default" for the default graph)
      model - Data.
    • put

      void put(org.apache.jena.rdf.model.Model model)
      Set the contents of the default graph of a dataset. Any existing data is lost. This is SPARQL Graph Store Protocol HTTP PUT or equivalent.
      Specified by:
      put in interface RDFDatasetConnection
      Parameters:
      model - Data.
    • delete

      void delete(String graphName)
      Delete a graph from the dataset. Null or "default" means the default graph, which is cleared, not removed.
      Specified by:
      delete in interface RDFDatasetConnection
      Parameters:
      graphName -
    • delete

      void delete()
      Remove all data from the default graph.
      Specified by:
      delete in interface RDFDatasetConnection
    • loadDataset

      void loadDataset(String file)
      Specified by:
      loadDataset in interface RDFDatasetConnection
    • loadDataset

      void loadDataset(org.apache.jena.query.Dataset dataset)
      Specified by:
      loadDataset in interface RDFDatasetConnection
    • putDataset

      void putDataset(String file)
      Specified by:
      putDataset in interface RDFDatasetConnection
    • putDataset

      void putDataset(org.apache.jena.query.Dataset dataset)
      Specified by:
      putDataset in interface RDFDatasetConnection
    • isClosed

      boolean isClosed()
      Test whether this connection is closed or not
      Specified by:
      isClosed in interface RDFDatasetAccessConnection
      Specified by:
      isClosed in interface RDFDatasetConnection
    • close

      void close()
      Close this connection. Use with try-resource.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface RDFDatasetAccessConnection
      Specified by:
      close in interface RDFDatasetConnection
      Specified by:
      close in interface SparqlQueryConnection
      Specified by:
      close in interface SparqlUpdateConnection