SAXEventRecorder (dom4j 1.6.1 API)

dom4j API


org.dom4j.io Class SAXEventRecorder

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.dom4j.io.SAXEventRecorder
All Implemented Interfaces:
ContentHandler, DeclHandler, DTDHandler, EntityResolver, ErrorHandler, Externalizable, LexicalHandler, Serializable

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();
  
   
  
 

Author:
Todd Wolff (Bluestem Software)
See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
Constructor Summary
SAXEventRecorder()
           
 
Method Summary
 void attributeDecl(String eName, String aName, String type, String valueDefault, String value)
           
 void characters(char[] ch, int start, int end)
           
 void comment(char[] ch, int start, int end)
           
 void elementDecl(String name, String model)
           
 void endCDATA()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(String namespaceURI, String localName, String qName)
           
 void endEntity(String name)
           
 void endPrefixMapping(String prefix)
           
 void externalEntityDecl(String name, String publicId, String sysId)
           
 void internalEntityDecl(String name, String value)
           
 void processingInstruction(String target, String data)
           
 void readExternal(ObjectInput in)
           
 void replay(ContentHandler handler)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes)
           
 void startEntity(String name)
           
 void startPrefixMapping(String prefix, String uri)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

SAXEventRecorder

public SAXEventRecorder()
Method Detail

replay

public void replay(ContentHandler handler)
            throws SAXException
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qualifiedName,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int end)
                throws SAXException
Specified by:
characters in interface ContentHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int end)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

elementDecl

public void elementDecl(String name,
                        String model)
                 throws SAXException
Specified by:
elementDecl in interface DeclHandler
Throws:
SAXException

attributeDecl

public void attributeDecl(String eName,
                          String aName,
                          String type,
                          String valueDefault,
                          String value)
                   throws SAXException
Specified by:
attributeDecl in interface DeclHandler
Throws:
SAXException

internalEntityDecl

public void internalEntityDecl(String name,
                               String value)
                        throws SAXException
Specified by:
internalEntityDecl in interface DeclHandler
Throws:
SAXException

externalEntityDecl

public void externalEntityDecl(String name,
                               String publicId,
                               String sysId)
                        throws SAXException
Specified by:
externalEntityDecl in interface DeclHandler
Throws:
SAXException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws ClassNotFoundException,
                         IOException
Specified by:
readExternal in interface Externalizable
Throws:
ClassNotFoundException
IOException


Copyright © 2001-2005 MetaStuff Ltd.. All Rights Reserved.