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_INDENTATION

    Fields 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 Type
    Method
    Description
    void
    Stores all xml data which has been written since markSavePoint() has been called to the underlying writer.
    boolean
    Tells whether or not undoable writing has been started or not.
    void
    Starts undoable xml writing.
    void
    Discards all xml data which has been written since markSavePoint() 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • markSavePoint

      public void markSavePoint()
      Starts undoable xml writing. Be sure to call either commitSavePoint() or restoreSavePoint() at the end of undoable writing period.
      Throws:
      IllegalStateException - if called twice before either commitSavePoint() or restoreSavePoint() 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 since markSavePoint() 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 since markSavePoint() has been called to the underlying writer.

      From now on undoable writing is disabled until markSavePoint() is called again.