Class Transaction
java.lang.Object
com.github.robtimus.os.windows.registry.Transaction
A representation of transactions for working with the Windows registry.
Transaction can be started or by-passed using
TransactionalState.- Author:
- Rob Spoor
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe possible transaction statuses. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the transaction will be automatically committed when it ends.voidautoCommit(boolean autoCommit) Sets whether to automatically commit the transaction when it ends.voidcommit()Commits the transaction.static Optional<Transaction> current()Returns the current transaction, if one exists.Returns the transaction description.voidrollback()Rolls back the transaction.status()Returns the transaction status.timeout()Returns the transaction timeout.toString()
-
Method Details
-
timeout
-
description
Returns the transaction description.- Returns:
- An
Optionaldescribing the transaction description, orOptional.empty()if the transaction has no description.
-
status
Returns the transaction status.- Returns:
- The transaction status.
- Throws:
TransactionException- If the transaction status could not be determined.
-
autoCommit
public boolean autoCommit()Returns whether the transaction will be automatically committed when it ends. The default istrue.- Returns:
trueif the transaction will be automatically committed when it ends, orfalseotherwise.
-
autoCommit
public void autoCommit(boolean autoCommit) Sets whether to automatically commit the transaction when it ends. The default istrue.- Parameters:
autoCommit-trueto automatically commit the transaction when it ends, orfalseotherwise.
-
commit
public void commit()Commits the transaction.- Throws:
TransactionException- If the transaction could not be committed.
-
rollback
public void rollback()Rolls back the transaction.- Throws:
TransactionException- If the transaction could not be rolled back.
-
toString
-
current
Returns the current transaction, if one exists.- Returns:
- An
Optionaldescribing the current transaction if one exists, orOptional.empty()otherwise.
-