Interface RDFLink

All Superinterfaces:
AutoCloseable, LinkDatasetGraph, LinkDatasetGraphAccess, LinkSparqlQuery, LinkSparqlUpdate, Transactional
All Known Implementing Classes:
RDFLinkAdapter, RDFLinkDataset, RDFLinkFuseki, RDFLinkHTTP, RDFLinkModular

Interface for SPARQL operations on a dataset, whether local or remote. Operations can be 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). RDFLink 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:
  • Method Details

    • connect

      static RDFLink connect(DatasetGraph dataset)
      Connect to a local (same JVM) dataset. The default isolation is NONE. See connect(DatasetGraph, Isolation) to select an isolation mode.
      Parameters:
      dataset -
      Returns:
      RDFLink
      See Also:
    • connect

      static RDFLink connect(DatasetGraph dataset, Isolation isolation)
      Connect to a local (same JVM) dataset.

      Multiple levels of Isolation are provided, The default COPY level makes a local RDFLink 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 RDFLink queryConnect(String queryServiceURL)
      Create a connection to a remote location for SPARQL query requests
      Parameters:
      queryServiceURL -
      Returns:
      RDFConnection
    • connect

      static RDFLink 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 RDFLinkHTTP.newBuilder() and setting the endpoint URLs.

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

      static RDFLink 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
    • queryRowSet

      default void queryRowSet(String queryString, Consumer<RowSet> rowSetAction)
      Execute a SELECT query and process the RowSet with the handler code.
      Specified by:
      queryRowSet in interface LinkSparqlQuery
      Parameters:
      queryString -
      rowSetAction -
    • queryRowSet

      default void queryRowSet(Query query, Consumer<RowSet> rowSetAction)
      Execute a SELECT query and process the RowSet with the handler code.
      Specified by:
      queryRowSet in interface LinkSparqlQuery
      Parameters:
      query -
      rowSetAction -
    • querySelect

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

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

      default Graph queryConstruct(String queryString)
      Execute a CONSTRUCT query and return as a Graph
      Specified by:
      queryConstruct in interface LinkSparqlQuery
    • queryConstructDataset

      default DatasetGraph queryConstructDataset(Query query)
      Execute a CONSTRUCT query and return as a DatasetGraph
    • queryConstructDataset

      default DatasetGraph queryConstructDataset(String queryString)
      Execute a CONSTRUCT query and return as a Graph
    • queryConstruct

      default Graph queryConstruct(Query query)
      Execute a CONSTRUCT query and return as a Graph
      Specified by:
      queryConstruct in interface LinkSparqlQuery
    • queryDescribe

      default Graph queryDescribe(String queryString)
      Execute a DESCRIBE query and return as a Graph
      Specified by:
      queryDescribe in interface LinkSparqlQuery
    • queryDescribe

      default Graph queryDescribe(Query query)
      Execute a DESCRIBE query and return as a Graph
      Specified by:
      queryDescribe in interface LinkSparqlQuery
    • queryAsk

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

      default boolean queryAsk(Query query)
      Execute a ASK query and return a boolean
      Specified by:
      queryAsk in interface LinkSparqlQuery
    • query

      QueryExec 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 LinkSparqlQuery
      Parameters:
      query -
      Returns:
      QueryExecution
    • query

      default QueryExec 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 LinkSparqlQuery
      Parameters:
      queryString -
      Returns:
      QueryExecution
    • newQuery

      QueryExecBuilder newQuery()
      Return a QueryExecBuilder that is initially configured for this link setup and type. The query built will be set to go to the same dataset/remote endpoint as the other RDFLink operations.
      Specified by:
      newQuery in interface LinkSparqlQuery
      Returns:
      QueryExecBuilder
    • newUpdate

      UpdateExecBuilder newUpdate()
      Return a UpdateExecBuilder 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 LinkSparqlUpdate
      Returns:
      UpdateExecBuilder
    • update

      default void update(Update update)
      Execute a SPARQL Update.
      Specified by:
      update in interface LinkSparqlUpdate
      Parameters:
      update -
    • update

      void update(UpdateRequest update)
      Execute a SPARQL Update.
      Specified by:
      update in interface LinkSparqlUpdate
      Parameters:
      update -
    • update

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

      Graph get()
      Fetch the default graph. This is SPARQL Graph Store Protocol HTTP GET or equivalent.
      Specified by:
      get in interface LinkDatasetGraphAccess
      Returns:
      Graph
    • get

      Graph get(Node graphName)
      Fetch a named graph. This is SPARQL Graph Store Protocol HTTP GET or equivalent.
      Specified by:
      get in interface LinkDatasetGraphAccess
      Parameters:
      graphName - URI string for the graph name (null or Quad.defaultGraphIRI for the default graph)
      Returns:
      Graph
    • load

      void load(String file)
      Send file - this merges the file RDF into the default graph of a dataset. This is SPARQL Graph Store Protocol HTTP POST or equivalent.

      If this is a remote connection:

      • The file is sent as-is and not parsed in the RDFLink
      • The Content-Type is determined by the filename
      Specified by:
      load in interface LinkDatasetGraph
      Parameters:
      file - File of the data.
    • load

      void load(Node graphName, String file)
      Load (add, append) RDF into a named graph in a dataset. This is SPARQL Graph Store Protocol HTTP POST or equivalent.

      If this is a remote connection:

      • The file is sent as-is and not parsed in the RDFLink
      • The Content-Type is determined by the filename
      Specified by:
      load in interface LinkDatasetGraph
      Parameters:
      graphName - Graph name (null or Quad.defaultGraphIRI for the default graph)
      file - File of the data.
    • load

      void load(Graph graph)
      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 LinkDatasetGraph
      Parameters:
      graph - Data.
    • load

      void load(Node graphName, Graph graph)
      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 LinkDatasetGraph
      Parameters:
      graphName - Graph name (null or Quad.defaultGraphIRI for the default graph)
      graph - 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.

      If this is a remote connection:

      • The file is sent as-is and not parsed in the RDFLink
      • The Content-Type is determined by the filename
      Specified by:
      put in interface LinkDatasetGraph
      Parameters:
      file - File of the data.
    • put

      void put(Node 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 LinkDatasetGraph
      Parameters:
      graphName - Graph name (null or Quad.defaultGraphIRI for the default graph)
      file - File of the data.
    • put

      void put(Graph graph)
      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.

      If this is a remote connection:

      • The file is sent as-is and not parsed in the RDFLink
      • The Content-Type is determined by the filename
      Specified by:
      put in interface LinkDatasetGraph
      Parameters:
      graph - Data.
    • put

      void put(Node graphName, Graph graph)
      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 LinkDatasetGraph
      Parameters:
      graphName - Graph name (null or Quad.defaultGraphIRI for the default graph)
      graph - Data.
    • delete

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

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

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

      void loadDataset(DatasetGraph dataset)
      Specified by:
      loadDataset in interface LinkDatasetGraph
    • putDataset

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

      void putDataset(DatasetGraph dataset)
      Specified by:
      putDataset in interface LinkDatasetGraph
    • clearDataset

      void clearDataset()
      Clear the dataset - remove all named graphs, clear the default graph.
      Specified by:
      clearDataset in interface LinkDatasetGraph
    • isClosed

      boolean isClosed()
      Test whether this connection is closed or not
      Specified by:
      isClosed in interface LinkDatasetGraph
      Specified by:
      isClosed in interface LinkDatasetGraphAccess
    • isRemote

      default boolean isRemote()
      Whether this RDFLink is to a remote server or not.
    • close

      void close()
      Close this connection. Use with try-resource.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface LinkDatasetGraph
      Specified by:
      close in interface LinkDatasetGraphAccess
      Specified by:
      close in interface LinkSparqlQuery
      Specified by:
      close in interface LinkSparqlUpdate