Package de.hybris.bootstrap.xml
Class UndoableXMLOutputter
java.lang.Object
org.znerd.xmlenc.XMLOutputter
de.hybris.bootstrap.xml.UndoableXMLOutputter
- All Implemented Interfaces:
org.znerd.xmlenc.StatefulXMLEventListener,org.znerd.xmlenc.XMLEventListener,org.znerd.xmlenc.XMLEventListenerStates
public class UndoableXMLOutputter
extends org.znerd.xmlenc.XMLOutputter
XML outputter wrapper implementation which allows to write a certain amount of data and removing it
afterwards from the output. This class uses a
UndoableWriterWrapper instance.
UndoableXMLOutputter xout = new UndoableXMLOutputter(actualWriter);
// start undoable writing
xout.markSavePoint();
try
{
// ... write xml ...
// finally store changes
xout.commitSavePoint();
}
catch (Exception e)
{
// discard any changes and restore outputter state
xout.restoreSavePoint();
}
-
Field Summary
Fields inherited from class org.znerd.xmlenc.XMLOutputter
DEFAULT_INDENTATIONFields inherited from interface org.znerd.xmlenc.XMLEventListenerStates
AFTER_ROOT_ELEMENT, BEFORE_DTD_DECLARATION, BEFORE_ROOT_ELEMENT, BEFORE_XML_DECLARATION, DOCUMENT_ENDED, ERROR_STATE, START_TAG_OPEN, UNINITIALIZED, WITHIN_ELEMENT -
Method Summary
Modifier and TypeMethodDescriptionvoidStores all xml data which has been written sincemarkSavePoint()has been called to the underlying writer.booleanTells whether or not undoable writing has been started or not.voidStarts undoable xml writing.voidDiscards all xml data which has been written sincemarkSavePoint()has been called.Methods inherited from class org.znerd.xmlenc.XMLOutputter
attribute, cdata, close, comment, declaration, dtd, endDocument, endTag, getElementStack, getElementStackCapacity, getElementStackSize, getEncoding, getIndentation, getLineBreak, getQuotationMark, getState, getWriter, isEscaping, pcdata, pcdata, pi, reset, reset, reset, setElementStackCapacity, setEscaping, setIndentation, setLineBreak, setQuotationMark, setState, startTag, whitespace, whitespace
-
Method Details
-
markSavePoint
public void markSavePoint()Starts undoable xml writing. Be sure to call eithercommitSavePoint()orrestoreSavePoint()at the end of undoable writing period.- Throws:
IllegalStateException- if called twice before eithercommitSavePoint()orrestoreSavePoint()have been called
-
hasSavePoint
public boolean hasSavePoint()Tells whether or not undoable writing has been started or not. -
restoreSavePoint
public void restoreSavePoint()Discards all xml data which has been written sincemarkSavePoint()has been called. The prevous outputter state is restored (opened tag, indentation level, ... ).From now on undoable writing is disabled until
markSavePoint()is called again. -
commitSavePoint
public void commitSavePoint()Stores all xml data which has been written sincemarkSavePoint()has been called to the underlying writer.From now on undoable writing is disabled until
markSavePoint()is called again.
-