- All Implemented Interfaces:
Dataset
,Transactional
- Direct Known Subclasses:
DatasetOne
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.jena.sparql.core.Transactional
Transactional.Promote
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Abort a transaction - finish the transaction and undo any changes (if a "write" transaction)addNamedModel
(String uri, Model model) Add a named graph.addNamedModel
(Resource uri, Model model) Add a named graph.Get the dataset in graph formvoid
begin()
Start a transaction which is READ mode and which will switch to WRITE if an update is attempted but only if no intermediate transaction has performed an update.void
Start either a READ or WRITE transactionvoid
Start a transaction.
READ or WRITE transactions start in that state and do not change for the lifetime of the transaction.void
close()
Close the dataset, potentially releasing any associated resources.void
commit()
Commit a transaction - finish the transaction and make any changes permanent (if a "write" transaction)boolean
containsNamedModel
(String uri) Does the dataset contain a model with the name supplied?boolean
Does the dataset contain a model named by the resource supplied?void
end()
Finish the transaction - if a write transaction and commit() has not been called, then abortGet the context associated with this datasetGet the default graph as a Jena ModelgetLock()
Get the lock for this datasetgetNamedModel
(String uri) Get a graph by name as a Jena ModelgetNamedModel
(Resource uri) Get a graph by resource as a Jena ModelGet the graph which is the union of all named graphs as a Jena Modelboolean
isEmpty()
boolean
Say whether a transaction is activeList the namesList the namesboolean
promote
(Transactional.Promote txnType) Attempt to promote a transaction from "read" mode to "write" and the transaction.removeNamedModel
(String uri) Remove a named graph.removeNamedModel
(Resource uri) Remove a named graph.replaceNamedModel
(String uri, Model model) Change a named graph for another using the same namereplaceNamedModel
(Resource uri, Model model) Change a named graph for another using the same namesetDefaultModel
(Model model) Set the default graph.boolean
Declare whetherDataset.abort()
is supported.boolean
Does this dataset support transactions? Supporting transactions means that the dataset implementation providesDataset.begin(org.apache.jena.query.ReadWrite)
,Dataset.commit()
,Dataset.end()
which otherwise may throwUnsupportedOperationException
.Return the current mode of the transaction - "read" or "write".Return the transaction type used inbegin(TxnType)
.static Dataset
wrap
(DatasetGraph datasetGraph) Wrap an existing DatasetGraphMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.jena.query.Dataset
getPrefixMapping
Methods inherited from interface org.apache.jena.sparql.core.Transactional
calc, calculate, calculateRead, calculateWrite, exec, execute, executeRead, executeWrite, promote
-
Constructor Details
-
DatasetImpl
Create a Dataset with the model as default model. Named models must be explicitly added to identify the storage to be used.
-
-
Method Details
-
wrap
Wrap an existing DatasetGraph -
getDefaultModel
Description copied from interface:Dataset
Get the default graph as a Jena Model- Specified by:
getDefaultModel
in interfaceDataset
-
getUnionModel
Description copied from interface:Dataset
Get the graph which is the union of all named graphs as a Jena Model- Specified by:
getUnionModel
in interfaceDataset
-
getLock
Description copied from interface:Dataset
Get the lock for this dataset -
getContext
Description copied from interface:Dataset
Get the context associated with this dataset- Specified by:
getContext
in interfaceDataset
-
supportsTransactions
public boolean supportsTransactions()Description copied from interface:Dataset
Does this dataset support transactions? Supporting transactions means that the dataset implementation providesDataset.begin(org.apache.jena.query.ReadWrite)
,Dataset.commit()
,Dataset.end()
which otherwise may throwUnsupportedOperationException
.See
Dataset.supportsTransactionAbort()
forDataset.abort()
. ADataset
that provides functionality across independent systems can not provide all features strong guarantees. For example, they may use MRSW locking and some isolation control. Specifically, they do not necessarily provideDataset.abort()
.In addition, check details of a specific implementation.
- Specified by:
supportsTransactions
in interfaceDataset
-
supportsTransactionAbort
public boolean supportsTransactionAbort()Description copied from interface:Dataset
Declare whetherDataset.abort()
is supported. This goes along with clearing up after exceptions inside application transaction code.- Specified by:
supportsTransactionAbort
in interfaceDataset
-
begin
public void begin()Description copied from interface:Transactional
Start a transaction which is READ mode and which will switch to WRITE if an update is attempted but only if no intermediate transaction has performed an update.See
Transactional.begin(TxnType)
for more details an options.May not be implemented. See
Transactional.begin(ReadWrite)
is guaranteed to be provided.- Specified by:
begin
in interfaceTransactional
-
begin
Description copied from interface:Transactional
Start a transaction.
READ or WRITE transactions start in that state and do not change for the lifetime of the transaction.WRITE
: this guarantees a WRITE will complete ifcommit()
is called. The same asbegin(ReadWrite.WRITE)
.READ
: the transaction can not promote to WRITE,ensuring read-only access to the data. The same asbegin(ReadWrite.READ)
.READ_PROMOTE
: the transaction will go from "read" to "write" if an update is attempted and if the dataset has not been changed by another write transaction. See alsoTransactional.promote()
.READ_COMMITTED_PROMOTE
: Use this with care. The promotion will succeed but changes from other transactions become visible.
begin
). IfREAD_PROMOTE
, the dataset must not have changed; ifREAD_COMMITTED_PROMOTE
any intermediate changes are visible but the application can not assume any data it has read in the transaction is the same as it was at the point the transaction started.This operation is optional and some implementations may throw a
JenaTransactionException
exception for some or allTxnType
values.See
Transactional.begin(ReadWrite)
for a form that is required of implementations.- Specified by:
begin
in interfaceTransactional
-
begin
Description copied from interface:Dataset
Start either a READ or WRITE transaction- Specified by:
begin
in interfaceDataset
- Specified by:
begin
in interfaceTransactional
-
promote
Description copied from interface:Transactional
Attempt to promote a transaction from "read" mode to "write" and the transaction. This method allows the form of promotion to be specified. The transaction must not have been started withREAD
, which is read-only.An argument of
READ_PROMOTE
treats the promotion as if the transaction was started withREAD_PROMOTE
(any other writer commiting since the transaction started blocks promotion) andREAD_COMMITTED_PROMOTE
treats the promotion as if the transaction was started withREAD_COMMITTED_PROMOTE
(intemediate writer commits become visible).Returns "true" if the transaction is in write mode after the call. The method always succeeds of the transaction is already "write".
This method returns true if a
READ_PROMOTE
orREAD_COMMITTED_PROMOTE
is promoted.This method returns false if a
READ_PROMOTE
can't be promoted - the transaction is still valid and in "read" mode.This method throws an exception if there is an attempt to promote a
READ
transaction.- Specified by:
promote
in interfaceTransactional
-
transactionMode
Description copied from interface:Transactional
Return the current mode of the transaction - "read" or "write". If the caller is not in a transaction, this method returns null.- Specified by:
transactionMode
in interfaceTransactional
-
transactionType
Description copied from interface:Transactional
Return the transaction type used inbegin(TxnType)
. If the caller is not in a transaction, this method returns null.- Specified by:
transactionType
in interfaceTransactional
-
isInTransaction
public boolean isInTransaction()Say whether a transaction is active- Specified by:
isInTransaction
in interfaceDataset
- Specified by:
isInTransaction
in interfaceTransactional
-
commit
public void commit()Description copied from interface:Dataset
Commit a transaction - finish the transaction and make any changes permanent (if a "write" transaction)- Specified by:
commit
in interfaceDataset
- Specified by:
commit
in interfaceTransactional
-
abort
public void abort()Description copied from interface:Dataset
Abort a transaction - finish the transaction and undo any changes (if a "write" transaction)- Specified by:
abort
in interfaceDataset
- Specified by:
abort
in interfaceTransactional
-
end
public void end()Description copied from interface:Dataset
Finish the transaction - if a write transaction and commit() has not been called, then abort- Specified by:
end
in interfaceDataset
- Specified by:
end
in interfaceTransactional
-
asDatasetGraph
Description copied from interface:Dataset
Get the dataset in graph form- Specified by:
asDatasetGraph
in interfaceDataset
-
getNamedModel
Description copied from interface:Dataset
Get a graph by name as a Jena Model- Specified by:
getNamedModel
in interfaceDataset
-
getNamedModel
Description copied from interface:Dataset
Get a graph by resource as a Jena Model- Specified by:
getNamedModel
in interfaceDataset
-
addNamedModel
Description copied from interface:Dataset
Add a named graph.- Specified by:
addNamedModel
in interfaceDataset
- Parameters:
uri
- the name of the graph to setmodel
- the graph to set- Returns:
- this
Dataset
for continued usage
-
addNamedModel
Description copied from interface:Dataset
Add a named graph.- Specified by:
addNamedModel
in interfaceDataset
- Parameters:
uri
- the name of the graph to setmodel
- the graph to set- Returns:
- this
Dataset
for continued usage
-
removeNamedModel
Description copied from interface:Dataset
Remove a named graph.- Specified by:
removeNamedModel
in interfaceDataset
- Parameters:
uri
- the name of the graph to remove- Returns:
- this
Dataset
for continued usage
-
removeNamedModel
Description copied from interface:Dataset
Remove a named graph.- Specified by:
removeNamedModel
in interfaceDataset
- Parameters:
uri
- the name of the graph to remove- Returns:
- this
Dataset
for continued usage
-
replaceNamedModel
Description copied from interface:Dataset
Change a named graph for another using the same name- Specified by:
replaceNamedModel
in interfaceDataset
- Parameters:
uri
- the name of the graph to replacemodel
- the graph with which to replace it- Returns:
- this
Dataset
for continued usage
-
replaceNamedModel
Description copied from interface:Dataset
Change a named graph for another using the same name- Specified by:
replaceNamedModel
in interfaceDataset
- Parameters:
uri
- the name of the graph to replacemodel
- the graph with which to replace it- Returns:
- this
Dataset
for continued usage
-
setDefaultModel
Description copied from interface:Dataset
Set the default graph. This operation copies the statements from the model into the default graph of the dataset.- Specified by:
setDefaultModel
in interfaceDataset
- Parameters:
model
- the default graph to set- Returns:
- this
Dataset
for continued usage
-
containsNamedModel
Description copied from interface:Dataset
Does the dataset contain a model with the name supplied?- Specified by:
containsNamedModel
in interfaceDataset
-
containsNamedModel
Description copied from interface:Dataset
Does the dataset contain a model named by the resource supplied?- Specified by:
containsNamedModel
in interfaceDataset
-
listNames
Description copied from interface:Dataset
List the names -
listModelNames
Description copied from interface:Dataset
List the names- Specified by:
listModelNames
in interfaceDataset
-
close
public void close()Description copied from interface:Dataset
Close the dataset, potentially releasing any associated resources. The dataset can not be used for query after this call. -
isEmpty
public boolean isEmpty()
-