Package org.dellroad.stuff.pobj
Class PersistentFileTransaction
java.lang.Object
org.dellroad.stuff.pobj.PersistentFileTransaction
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
ConstructorDescriptionPersistentFileTransaction
(Source source) Constructor.PersistentFileTransaction
(Source source, TransformerFactory transformerFactory) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetData()
Get the current XML data.Get the system ID of the original source input.Get the updates list associated with this transaction.void
Change the current XML data.toString()
void
transform
(Transformer transformer) Apply an XSLT transform to the current XML object in this transaction.
-
Constructor Details
-
PersistentFileTransaction
Constructor.- Parameters:
source
- XML input- Throws:
PersistentObjectException
- if no updates are foundIllegalArgumentException
- ifsource
is nullXMLStreamException
- if XML parsing failsIOException
- if an I/O error occurs
-
PersistentFileTransaction
public PersistentFileTransaction(Source source, TransformerFactory transformerFactory) throws IOException, XMLStreamException Constructor.- Parameters:
source
- XML inputtransformerFactory
- transformer factory, or null for platform default- Throws:
PersistentObjectException
- if no updates are foundIllegalArgumentException
- ifsource
is nullXMLStreamException
- if XML parsing failsIOException
- if an I/O error occurs
-
-
Method Details
-
getData
Get the current XML data. Does not include the XML update list.During a schema update the caller may modify the document in place, or invoke
setData(org.w3c.dom.Document)
to completely replace it.- Returns:
- XML data
-
setData
Change the current XML data.This would be invoked by a schema update if it wanted to completely replace the XML document, rather than just modifying it in place.
- Parameters:
data
- new XML data; does not include the XML update list
-
getSystemId
Get the system ID of the original source input.- Returns:
- XML system ID
-
getUpdates
Get the updates list associated with this transaction.- Returns:
- list of updates
-
transform
Apply an XSLT transform to the current XML object in this transaction.This is an alternative to modifying the DOM, when XSL is a simpler way to perform the update.
- Parameters:
transformer
- XSLT transformer- Throws:
IllegalStateException
- if the current root object is nullPersistentObjectException
- if an error occursTransformerException
- if the transformation fails
-
toString
-