Class Transaction

java.lang.Object
com.github.robtimus.os.windows.registry.Transaction

public final class Transaction extends Object
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
  • Method Details

    • timeout

      public Duration timeout()
      Returns the transaction timeout.
      Returns:
      The transaction timeout. If zero there is an infinite timeout.
    • description

      public Optional<String> description()
      Returns the transaction description.
      Returns:
      An Optional describing the transaction description, or Optional.empty() if the transaction has no description.
    • status

      public Transaction.Status 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 is true.
      Returns:
      true if the transaction will be automatically committed when it ends, or false otherwise.
    • autoCommit

      public void autoCommit(boolean autoCommit)
      Sets whether to automatically commit the transaction when it ends. The default is true.
      Parameters:
      autoCommit - true to automatically commit the transaction when it ends, or false otherwise.
    • 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

      public String toString()
      Overrides:
      toString in class Object
    • current

      public static Optional<Transaction> current()
      Returns the current transaction, if one exists.
      Returns:
      An Optional describing the current transaction if one exists, or Optional.empty() otherwise.