- All Superinterfaces:
AutoCloseable
,RDFDatasetAccessConnection
,RDFDatasetConnection
,SparqlQueryConnection
,SparqlUpdateConnection
,Transactional
- All Known Subinterfaces:
RDFConnectionFuseki
,RDFConnectionRemote
- All Known Implementing Classes:
RDFConnectionAdapter
,RDFConnectionFuseki.RDFConnectionFusekiImpl
,RDFConnectionLocal
,RDFConnectionWrapper
public interface RDFConnection
extends SparqlQueryConnection, SparqlUpdateConnection, RDFDatasetConnection, 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.
- query (
SparqlQueryConnection
) - update (
SparqlUpdateConnection
) - graph store protocol (
RDFDatasetConnection
).
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.jena.sparql.core.Transactional
Transactional.Promote
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this connection.static RDFConnection
Create a connection to a remote location by URL.static RDFConnection
Connect to a local (same JVM) dataset.static RDFConnection
Connect to a local (same JVM) dataset.static RDFConnection
Make a remote RDFConnection to the URL, with user and password for the client access using basic auth.void
delete()
Remove all data from the default graph.void
Delete a graph from the dataset.fetch()
Fetch the default graph.Fetch a named graph.Fetch the contents of the datasetboolean
isClosed()
Test whether this connection is closed or notvoid
Load (add, append) RDF into the default graph of a dataset.void
Load (add, append) RDF into a named graph in a dataset.void
Load (add, append) RDF into a named graph in a dataset.void
Load (add, append) RDF into the default graph of a dataset.void
loadDataset
(String file) void
loadDataset
(Dataset dataset) newQuery()
Return a execution builder initialized with the RDFConnection setup.Return aUpdateExecutionBuilder
that is initially configured for this link setup and type.void
Set the contents of the default graph of a dataset.void
Set the contents of a named graph of a dataset.void
Set the contents of a named graph of a dataset.void
Set the contents of the default graph of a dataset.void
putDataset
(String file) void
putDataset
(Dataset dataset) default QueryExecution
Setup a SPARQL query execution.Setup a SPARQL query execution.default boolean
Execute a ASK query and return a booleandefault boolean
Execute a ASK query and return a booleanstatic RDFConnection
queryConnect
(String queryServiceURL) Create a connection to a remote location for SPARQL query requestsdefault Model
queryConstruct
(String queryString) Execute a CONSTRUCT query and return as a Modeldefault Model
queryConstruct
(Query query) Execute a CONSTRUCT query and return as a Modeldefault Model
queryDescribe
(String queryString) Execute a DESCRIBE query and return as a Modeldefault Model
queryDescribe
(Query query) Execute a DESCRIBE query and return as a Modeldefault void
queryResultSet
(String queryString, Consumer<ResultSet> resultSetAction) Execute a SELECT query and process the ResultSet with the handler code.default void
queryResultSet
(Query query, Consumer<ResultSet> resultSetAction) Execute a SELECT query and process the ResultSet with the handler code.default void
querySelect
(String queryString, Consumer<QuerySolution> rowAction) Execute a SELECT query and process the rows of the results with the handler code.default void
querySelect
(Query query, Consumer<QuerySolution> rowAction) Execute a SELECT query and process the rows of the results with the handler code.default void
Execute a SPARQL Update.default void
Execute a SPARQL Update.void
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
Connect to a local (same JVM) dataset. The default isolation isNONE
. Seeconnect(Dataset, Isolation)
to select an isolation mode.- Parameters:
dataset
-- Returns:
- RDFConnection
- See Also:
-
connect
Connect to a local (same JVM) dataset.Multiple levels of
Isolation
are provided, The defaultCOPY
level makes a localRDFConnection
behave like a remote connection. See the documentation for more details.COPY
–Model
s andDataset
s 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 returnedModel
s orDataset
s act on the original object.
- Parameters:
dataset
-isolation
-- Returns:
- RDFConnection
-
queryConnect
Create a connection to a remote location for SPARQL query requests- Parameters:
queryServiceURL
-- Returns:
- RDFConnection
-
connect
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
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
Execute a SELECT query and process the ResultSet with the handler code.- Specified by:
queryResultSet
in interfaceSparqlQueryConnection
- Parameters:
queryString
-resultSetAction
-
-
queryResultSet
Execute a SELECT query and process the ResultSet with the handler code.- Specified by:
queryResultSet
in interfaceSparqlQueryConnection
- Parameters:
query
-resultSetAction
-
-
querySelect
Execute a SELECT query and process the rows of the results with the handler code.- Specified by:
querySelect
in interfaceSparqlQueryConnection
- Parameters:
queryString
-rowAction
-
-
querySelect
Execute a SELECT query and process the rows of the results with the handler code.- Specified by:
querySelect
in interfaceSparqlQueryConnection
- Parameters:
query
-rowAction
-
-
queryConstruct
Execute a CONSTRUCT query and return as a Model- Specified by:
queryConstruct
in interfaceSparqlQueryConnection
-
queryConstruct
Execute a CONSTRUCT query and return as a Model- Specified by:
queryConstruct
in interfaceSparqlQueryConnection
-
queryDescribe
Execute a DESCRIBE query and return as a Model- Specified by:
queryDescribe
in interfaceSparqlQueryConnection
-
queryDescribe
Execute a DESCRIBE query and return as a Model- Specified by:
queryDescribe
in interfaceSparqlQueryConnection
-
queryAsk
Execute a ASK query and return a boolean- Specified by:
queryAsk
in interfaceSparqlQueryConnection
-
queryAsk
Execute a ASK query and return a boolean- Specified by:
queryAsk
in interfaceSparqlQueryConnection
-
query
Setup a SPARQL query execution. See alsoquerySelect(Query, Consumer)
,queryConstruct(Query)
,queryDescribe(Query)
,queryAsk(Query)
for ways to execute queries for of a specific form.- Specified by:
query
in interfaceSparqlQueryConnection
- Parameters:
query
-- Returns:
- QueryExecution
-
query
Setup a SPARQL query execution. This is a low-level operation. Handling theQueryExecution
should be done with try-resource. SomeQueryExecutions
, such as ones connecting to a remote server, need to be properly closed to release system resources. See alsoquerySelect(String, Consumer)
,queryConstruct(String)
,queryDescribe(String)
,queryAsk(String)
for ways to execute queries of a specific form.- Specified by:
query
in interfaceSparqlQueryConnection
- Parameters:
queryString
-- Returns:
- QueryExecution
-
newQuery
QueryExecutionBuilder newQuery()Return a execution builder initialized with the RDFConnection setup.- Specified by:
newQuery
in interfaceSparqlQueryConnection
- Returns:
- QueryExecutionBuilderCommon
-
update
Execute a SPARQL Update.- Specified by:
update
in interfaceSparqlUpdateConnection
- Parameters:
update
-
-
update
Execute a SPARQL Update.- Specified by:
update
in interfaceSparqlUpdateConnection
- Parameters:
update
-
-
update
Execute a SPARQL Update.- Specified by:
update
in interfaceSparqlUpdateConnection
- Parameters:
updateString
-
-
newUpdate
UpdateExecutionBuilder newUpdate()Return aUpdateExecutionBuilder
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 interfaceSparqlUpdateConnection
- Returns:
- UpdateExecBuilder
-
fetch
Fetch a named graph. This is SPARQL Graph Store Protocol HTTP GET or equivalent.- Specified by:
fetch
in interfaceRDFDatasetAccessConnection
- Parameters:
graphName
- URI string for the graph name (null or "default" for the default graph)- Returns:
- Model
-
fetch
Model fetch()Fetch the default graph. This is SPARQL Graph Store Protocol HTTP GET or equivalent.- Specified by:
fetch
in interfaceRDFDatasetAccessConnection
- Returns:
- Model
-
fetchDataset
Dataset fetchDataset()Fetch the contents of the dataset- Specified by:
fetchDataset
in interfaceRDFDatasetAccessConnection
-
load
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 interfaceRDFDatasetConnection
- Parameters:
graphName
- Graph name (null or "default" for the default graph)file
- File of the data.
-
load
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 interfaceRDFDatasetConnection
- Parameters:
file
- File of the data.
-
load
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 interfaceRDFDatasetConnection
- Parameters:
graphName
- Graph name (null or "default" for the default graph)model
- Data.
-
load
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 interfaceRDFDatasetConnection
- Parameters:
model
- Data.
-
put
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 interfaceRDFDatasetConnection
- Parameters:
graphName
- Graph name (null or "default" for the default graph)file
- File of the data.
-
put
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 interfaceRDFDatasetConnection
- Parameters:
file
- File of the data.
-
put
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 interfaceRDFDatasetConnection
- Parameters:
graphName
- Graph name (null or "default" for the default graph)model
- Data.
-
put
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 interfaceRDFDatasetConnection
- Parameters:
model
- Data.
-
delete
Delete a graph from the dataset. Null or "default" means the default graph, which is cleared, not removed.- Specified by:
delete
in interfaceRDFDatasetConnection
- Parameters:
graphName
-
-
delete
void delete()Remove all data from the default graph.- Specified by:
delete
in interfaceRDFDatasetConnection
-
loadDataset
- Specified by:
loadDataset
in interfaceRDFDatasetConnection
-
loadDataset
- Specified by:
loadDataset
in interfaceRDFDatasetConnection
-
putDataset
- Specified by:
putDataset
in interfaceRDFDatasetConnection
-
putDataset
- Specified by:
putDataset
in interfaceRDFDatasetConnection
-
isClosed
boolean isClosed()Test whether this connection is closed or not- Specified by:
isClosed
in interfaceRDFDatasetAccessConnection
- Specified by:
isClosed
in interfaceRDFDatasetConnection
-
close
void close()Close this connection. Use with try-resource.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceRDFDatasetAccessConnection
- Specified by:
close
in interfaceRDFDatasetConnection
- Specified by:
close
in interfaceSparqlQueryConnection
- Specified by:
close
in interfaceSparqlUpdateConnection
-