public class DatasetImpl extends Object implements Dataset
Transactional.Promote| Constructor and Description |
|---|
DatasetImpl(Dataset ds)
Deprecated.
|
DatasetImpl(Model model)
Create a Dataset with the model as default model.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort a transaction - finish the transaction and undo any changes (if a "write" transaction)
|
Dataset |
addNamedModel(String uri,
Model model)
Set a named graph.
|
DatasetGraph |
asDatasetGraph()
Get the dataset in graph form
|
void |
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 |
begin(ReadWrite mode)
Start either a READ or WRITE transaction
|
void |
begin(TxnType txnType)
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?
|
void |
end()
Finish the transaction - if a write transaction and commit() has not been called, then abort
|
Context |
getContext()
Get the context associated with this dataset
|
Model |
getDefaultModel()
Get the default graph as a Jena Model
|
Lock |
getLock()
Get the lock for this dataset
|
Model |
getNamedModel(String uri)
Get a graph by name as a Jena Model
|
Model |
getUnionModel()
Get the graph which is the unionof all named graphs as a Jena Model
|
boolean |
isEmpty() |
boolean |
isInTransaction()
Say whether a transaction is active
|
Iterator<String> |
listNames()
List the names
|
boolean |
promote(Transactional.Promote txnType)
Attempt to promote a transaction from "read" mode to "write" and the transaction.
|
Dataset |
removeNamedModel(String uri)
Remove a named graph.
|
Dataset |
replaceNamedModel(String uri,
Model model)
Change a named graph for another using the same name
|
Dataset |
setDefaultModel(Model model)
Set the default graph.
|
boolean |
supportsTransactionAbort()
Declare whether
Dataset.abort() is supported. |
boolean |
supportsTransactions()
Does this dataset support transactions? Supporting transactions means that
the dataset implementation provides
Dataset.begin(org.apache.jena.query.ReadWrite), Dataset.commit(),
Dataset.end() which otherwise may throw
UnsupportedOperationException. |
ReadWrite |
transactionMode()
Return the current mode of the transaction - "read" or "write".
|
TxnType |
transactionType()
Return the transaction type used in
begin(TxnType). |
static Dataset |
wrap(DatasetGraph datasetGraph)
Wrap an existing DatasetGraph
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpromotepublic DatasetImpl(Model model)
@Deprecated public DatasetImpl(Dataset ds)
public static Dataset wrap(DatasetGraph datasetGraph)
public Model getDefaultModel()
DatasetgetDefaultModel in interface Datasetpublic Model getUnionModel()
DatasetgetUnionModel in interface Datasetpublic Lock getLock()
Datasetpublic Context getContext()
DatasetgetContext in interface Datasetpublic boolean supportsTransactions()
DatasetDataset.begin(org.apache.jena.query.ReadWrite), Dataset.commit(),
Dataset.end() which otherwise may throw
UnsupportedOperationException.
See Dataset.supportsTransactionAbort() for Dataset.abort().
A Dataset 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
provide Dataset.abort().
In addition, check details of a specific implementation.
supportsTransactions in interface Datasetpublic boolean supportsTransactionAbort()
DatasetDataset.abort() is supported.
This goes along with clearing up after exceptions inside application transaction code.supportsTransactionAbort in interface Datasetpublic void begin()
Transactional
See Transactional.begin(TxnType) for more details an options.
May not be implemented. See Transactional.begin(ReadWrite) is guaranteed to be provided.
begin in interface Transactionalpublic void begin(TxnType txnType)
TransactionalWRITE: this guarantees a WRITE will complete if commit() is
called. The same as begin(ReadWrite.WRITE).
READ: the transaction can not promote to WRITE,ensuring read-only
access to the data. The same as begin(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 also Transactional.promote().
READ_COMMITTED_PROMOTE: Use this with care. The promotion will
succeed but changes from other transactions become visible.
begin). If READ_PROMOTE, the dataset must not have
changed; if READ_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 all TxnType values.
See Transactional.begin(ReadWrite) for a form that is required of implementations.
begin in interface Transactionalpublic void begin(ReadWrite mode)
Datasetbegin in interface Datasetbegin in interface Transactionalpublic boolean promote(Transactional.Promote txnType)
TransactionalREAD, which is read-only.
An argument of READ_PROMOTE treats the promotion as if the transaction was started
with READ_PROMOTE (any other writer commiting since the transaction started
blocks promotion) and READ_COMMITTED_PROMOTE treats the promotion as if the transaction was started
with READ_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 or
READ_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.
promote in interface Transactionalpublic ReadWrite transactionMode()
TransactionaltransactionMode in interface Transactionalpublic TxnType transactionType()
Transactionalbegin(TxnType).
If the caller is not in a transaction, this method returns null.transactionType in interface Transactionalpublic boolean isInTransaction()
isInTransaction in interface DatasetisInTransaction in interface Transactionalpublic void commit()
Datasetcommit in interface Datasetcommit in interface Transactionalpublic void abort()
Datasetabort in interface Datasetabort in interface Transactionalpublic void end()
Datasetend in interface Datasetend in interface Transactionalpublic DatasetGraph asDatasetGraph()
DatasetasDatasetGraph in interface Datasetpublic Model getNamedModel(String uri)
DatasetgetNamedModel in interface Datasetpublic Dataset addNamedModel(String uri, Model model)
DatasetaddNamedModel in interface Dataseturi - the name of the graph to setmodel - the graph to setDataset for continued usagepublic Dataset removeNamedModel(String uri)
DatasetremoveNamedModel in interface Dataseturi - the name of the gaph to removeDataset for continued usagepublic Dataset replaceNamedModel(String uri, Model model)
DatasetreplaceNamedModel in interface Dataseturi - the name of the graph to replacemodel - the graph with which to replace itDataset for continued usagepublic Dataset setDefaultModel(Model model)
DatasetsetDefaultModel in interface Datasetmodel - the default graph to setDataset for continued usagepublic boolean containsNamedModel(String uri)
DatasetcontainsNamedModel in interface Datasetpublic Iterator<String> listNames()
Datasetpublic void close()
DatasetLicenced under the Apache License, Version 2.0