Package org.dom4j.io

Class SAXEventRecorder

  • All Implemented Interfaces:
    Externalizable, Serializable, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, DeclHandler, LexicalHandler

    public class SAXEventRecorder
    extends DefaultHandler
    implements LexicalHandler, DeclHandler, DTDHandler, Externalizable

    Records SAX events such that they may be "replayed" at a later time. Provides an alternative serialization approach when externalizing a DOM4J document. Rather than serializing a document as text and re-parsing, the sax events may be serialized instead.

    Example usage:
     
      
      
             SAXEventRecorder recorder = new SAXEventRecorder();
             SAXWriter saxWriter = new SAXWriter(recorder, recorder);
             saxWriter.write(document);
             out.writeObject(recorder);
             ...
             SAXEventRecorder recorder = (SAXEventRecorder)in.readObject();
             SAXContentHandler saxContentHandler = new SAXContentHandler();
             recorder.replay(saxContentHandler);
             Document document = saxContentHandler.getDocument();
      
       
      
     
    See Also:
    Serialized Form