org.dellroad.stuff.pobj
Class PersistentFileTransaction

java.lang.Object
  extended by org.dellroad.stuff.pobj.PersistentFileTransaction

public class PersistentFileTransaction
extends Object

Represents an open "transaction" on a PersistentObject's persistent file.

This class is used by PersistentObjectSchemaUpdater and would normally not be used directly.


Constructor Summary
PersistentFileTransaction(File file)
          Constructor.
 
Method Summary
 void addUpdate(String name)
          Add an update to the list associated with this transaction.
 void commit()
          Commit this transaction.
 byte[] getData()
          Get the current XML data.
 List<String> getUpdates()
          Get the updates list associated with this transaction.
 void rollback()
          Cancel this transaction.
 void setData(byte[] data)
          Set the current XML data.
 void transform(Transformer transformer)
          Apply an XSLT transform to the current XML object in this transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistentFileTransaction

public PersistentFileTransaction(File file)
                          throws IOException,
                                 XMLStreamException
Constructor.

Parameters:
file - persistent file
Throws:
PersistentObjectException - if no updates are found
IOException
XMLStreamException
Method Detail

getData

public byte[] getData()
Get the current XML data. Does not include the XML update list.


setData

public void setData(byte[] data)
Set the current XML data. Data should not include the XML update list.


commit

public void commit()
            throws IOException,
                   XMLStreamException
Commit this transaction. This results in the persistent file being atomically overwritten (including update list).

Throws:
IOException
XMLStreamException

rollback

public void rollback()
Cancel this transaction.


getUpdates

public List<String> getUpdates()
Get the updates list associated with this transaction.

Returns:
unmodifiable list of updates

addUpdate

public void addUpdate(String name)
Add an update to the list associated with this transaction.


transform

public void transform(Transformer transformer)
               throws TransformerException
Apply an XSLT transform to the current XML object in this transaction.

Throws:
IllegalStateException - if the current root object is null
PersistentObjectException - if an error occurs
TransformerException - if the transformation fails