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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private List
<SAXEventRecorder.SAXEvent> private static final byte
private static final byte
static final long
private static final byte
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
void
endDTD()
void
endElement
(String namespaceURI, String localName, String qName) void
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
void
replay
(ContentHandler handler) void
void
void
void
startElement
(String namespaceURI, String localName, String qualifiedName, Attributes attributes) void
startEntity
(String name) void
startPrefixMapping
(String prefix, String uri) void
Methods inherited from class DefaultHandler
error, fatalError, ignorableWhitespace, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl, warning
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ContentHandler
declaration
Methods inherited from interface DTDHandler
notationDecl, unparsedEntityDecl
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
STRING
private static final byte STRING- See Also:
-
OBJECT
private static final byte OBJECT- See Also:
-
NULL
private static final byte NULL- See Also:
-
events
-
prefixMappings
-
XMLNS
- See Also:
-
EMPTY_STRING
- See Also:
-
-
Constructor Details
-
SAXEventRecorder
public SAXEventRecorder()
-
-
Method Details
-
replay
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
startPrefixMapping
- Specified by:
startPrefixMapping
in interfaceContentHandler
- Overrides:
startPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
endPrefixMapping
- Specified by:
endPrefixMapping
in interfaceContentHandler
- Overrides:
endPrefixMapping
in classDefaultHandler
- Throws:
SAXException
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
- Throws:
SAXException
-
endDocument
- 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
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
- Throws:
SAXException
-
startDTD
- Specified by:
startDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
endDTD
- Specified by:
endDTD
in interfaceLexicalHandler
- Throws:
SAXException
-
startEntity
- Specified by:
startEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
endEntity
- Specified by:
endEntity
in interfaceLexicalHandler
- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Throws:
SAXException
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Throws:
SAXException
-
elementDecl
- 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
- Specified by:
internalEntityDecl
in interfaceDeclHandler
- Throws:
SAXException
-
externalEntityDecl
- Specified by:
externalEntityDecl
in interfaceDeclHandler
- Throws:
SAXException
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
ClassNotFoundException
IOException
-