Class 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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void commitSavePoint()
      Stores all xml data which has been written since markSavePoint() has been called to the underlying writer.
      boolean hasSavePoint()
      Tells whether or not undoable writing has been started or not.
      void markSavePoint()
      Starts undoable xml writing.
      void restoreSavePoint()
      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 Detail

      • 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.