Package org.dom4j.io
Class SAXEventRecorder
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.dom4j.io.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
-
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description SAXEventRecorder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
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 interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
startDocument
public void startDocument() throws SAXException
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
- Throws:
SAXException
-
startElement
public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException
- Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
endElement
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int end) throws SAXException
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
startDTD
public void startDTD(String name, String publicId, String systemId) throws SAXException
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
public void endDTD() throws SAXException
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
public void startEntity(String name) throws SAXException
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
public void endEntity(String name) throws SAXException
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
public void startCDATA() throws SAXException
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
public void endCDATA() throws SAXException
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
public void comment(char[] ch, int start, int end) throws SAXException
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
elementDecl
public void elementDecl(String name, String model) throws SAXException
- Specified by:
elementDecl
in interfaceDeclHandler
- Throws:
SAXException
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException
- Specified by:
attributeDecl
in interfaceDeclHandler
- Throws:
SAXException
-
internalEntityDecl
public void internalEntityDecl(String name, String value) throws SAXException
- Specified by:
internalEntityDecl
in interfaceDeclHandler
- Throws:
SAXException
-
externalEntityDecl
public void externalEntityDecl(String name, String publicId, String sysId) throws SAXException
- Specified by:
externalEntityDecl
in interfaceDeclHandler
- Throws:
SAXException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws ClassNotFoundException, IOException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
ClassNotFoundException
IOException
-
-