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();
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private List | |
| private static final byte | |
| private static final byte | |
| private Map | |
| public static final long | |
| private static final byte | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | attributeDecl(String
The name of the associated element. eName, String The name of the attribute. aName, String A string representing the attribute type. type, String A string representing the attribute defaulting mode
("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
none of these applies. valueDefault, String A string representing the attribute's default value,
or null if there is none. value)Implements org. |
| public void | characters(char[]
The characters. ch, int The start position in the character array. start, int The number of characters to use from the
character array. end)Overrides org. Implements org. |
| public void | comment(char[]
An array holding the characters in the comment. ch, int The starting position in the array. start, int The number of characters to use from the array. end)Implements org. |
| public void | elementDecl(String
The element type name. name, String The content model as a normalized string. model)Implements org. |
| public void | |
| public void | endDocument()
Overrides org. Implements org. |
| public void | |
| public void | endElement(String
The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed. namespaceURI, String The local name (without prefix), or the
empty string if Namespace processing is not being
performed. localName, String The qualified name (with prefix), or the
empty string if qualified names are not available. qName)Overrides org. Implements org. |
| public void | endEntity(String
The name of the entity that is ending. name)Implements org. |
| public void | endPrefixMapping(String
The Namespace prefix being declared. prefix)Overrides org. Implements org. |
| public void | externalEntityDecl(String
The name of the entity. If it is a parameter
entity, the name will begin with '%'. name, String The entity's public identifier, or null if none
was given. publicId, String The entity's system identifier. sysId)Implements org. |
| public void | internalEntityDecl(String
The name of the entity. If it is a parameter
entity, the name will begin with '%'. name, String The replacement text of the entity. value)Implements org. |
| public void | processingInstruction(String
The processing instruction target. target, String The processing instruction data, or null if
none is supplied. data)Overrides org. Implements org. |
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. |
| public void | |
| public void | startCDATA()
Implements org. |
| public void | startDocument()
Overrides org. Implements org. |
| public void | startDTD(String
The document type name. name, String The declared public identifier for the
external DTD subset, or null if none was declared. publicId, String The declared system identifier for the
external DTD subset, or null if none was declared.
(Note that this is not resolved against the document
base URI.) systemId)Implements org. |
| public void | startElement(String
The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed. namespaceURI, String The local name (without prefix), or the
empty string if Namespace processing is not being
performed. localName, String The qualified name (with prefix), or the
empty string if qualified names are not available. qualifiedName, Attributes The attributes attached to the element. If
there are no attributes, it shall be an empty
Attributes object. attributes)Overrides org. Implements org. |
| public void | startEntity(String
The name of the entity. If it is a parameter
entity, the name will begin with '%', and if it is the
external DTD subset, it will be "[dtd]". name)Implements org. |
| public void | startPrefixMapping(String
The Namespace prefix being declared. prefix, String The Namespace URI mapped to the prefix. uri)Overrides org. Implements org. |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. |
| EMPTY_STRING | back to summary |
|---|---|
| private static final String EMPTY_STRING | |
| events | back to summary |
|---|---|
| private List<SAXEventRecorder. | |
| NULL | back to summary |
|---|---|
| private static final byte NULL | |
| OBJECT | back to summary |
|---|---|
| private static final byte OBJECT | |
| prefixMappings | back to summary |
|---|---|
| private Map<QName, List<String>> prefixMappings | |
| serialVersionUID | back to summary |
|---|---|
| public static final long serialVersionUID | |
| STRING | back to summary |
|---|---|
| private static final byte STRING | |
| XMLNS | back to summary |
|---|---|
| private static final String XMLNS | |
| SAXEventRecorder | back to summary |
|---|---|
| public SAXEventRecorder() | |
| attributeDecl | back to summary |
|---|---|
| public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException Implements org. Doc from org. Report an attribute type declaration. Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group with the separator "|" and all whitespace removed, or the word "NOTATION" followed by a space followed by a parenthesized token group with all whitespace removed. The value will be the value as reported to applications, appropriately normalized and with entity and character references expanded.
| |
| characters | back to summary |
|---|---|
| public void characters(char[] ch, int start, int end) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of character data inside an element. By default, do nothing. Application writers may override this method to take specific actions for each chunk of character data (such as adding the data to a node or buffer, or printing it to a file).
| |
| comment | back to summary |
|---|---|
| public void comment(char[] ch, int start, int end) throws SAXException Implements org. Doc from org. Report an XML comment anywhere in the document. This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read). Comments in the DTD must be properly nested inside start/endDTD and start/endEntity events (if used).
| |
| elementDecl | back to summary |
|---|---|
| public void elementDecl(String name, String model) throws SAXException Implements org. Doc from org. Report an element type declaration. The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all parameter entities are fully resolved and all whitespace is removed, and will include the enclosing parentheses. Other normalization (such as removing redundant parentheses or simplifying occurrence indicators) is at the discretion of the parser.
| |
| endCDATA | back to summary |
|---|---|
| public void endCDATA() throws SAXException Implements org. Doc from org. Report the end of a CDATA section.
| |
| endDocument | back to summary |
|---|---|
| public void endDocument() throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the end of the document. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalising a tree or closing an output file).
| |
| endDTD | back to summary |
|---|---|
| public void endDTD() throws SAXException Implements org. Doc from org. Report the end of DTD declarations. This method is intended to report the end of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.
| |
| endElement | back to summary |
|---|---|
| public void endElement(String namespaceURI, String localName, String qName) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the end of an element. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
| |
| endEntity | back to summary |
|---|---|
| public void endEntity(String name) throws SAXException Implements org. Doc from org. Report the end of an entity.
| |
| endPrefixMapping | back to summary |
|---|---|
| public void endPrefixMapping(String prefix) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the end of a Namespace mapping. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each prefix mapping.
| |
| externalEntityDecl | back to summary |
|---|---|
| public void externalEntityDecl(String name, String publicId, String sysId) throws SAXException Implements org. Doc from org. Report a parsed external entity declaration. Only the effective (first) declaration for each entity will be reported. If the system identifier is a URL, the parser must resolve it fully before passing it to the application.
| |
| internalEntityDecl | back to summary |
|---|---|
| public void internalEntityDecl(String name, String value) throws SAXException Implements org. Doc from org. Report an internal entity declaration. Only the effective (first) declaration for each entity will be reported. All parameter entities in the value will be expanded, but general entities will not.
| |
| processingInstruction | back to summary |
|---|---|
| public void processingInstruction(String target, String data) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of a processing instruction. By default, do nothing. Application writers may override this method in a subclass to take specific actions for each processing instruction, such as setting status variables or invoking other methods.
| |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws ClassNotFoundException, IOException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| replay | back to summary |
|---|---|
| public void replay(ContentHandler handler) throws SAXException | |
| startCDATA | back to summary |
|---|---|
| public void startCDATA() throws SAXException Implements org. Doc from org. Report the start of a CDATA section. The contents of the CDATA section will be reported through
the regular
| |
| startDocument | back to summary |
|---|---|
| public void startDocument() throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the beginning of the document. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the beginning of a document (such as allocating the root node of a tree or creating an output file).
| |
| startDTD | back to summary |
|---|---|
| public void startDTD(String name, String publicId, String systemId) throws SAXException Implements org. Doc from org. Report the start of DTD declarations, if any. This method is intended to report the beginning of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked. All declarations reported through
Note that the start/endDTD events will appear within
the start/endDocument events from ContentHandler and
before the first
| |
| startElement | back to summary |
|---|---|
| public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the start of an element. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
| |
| startEntity | back to summary |
|---|---|
| public void startEntity(String name) throws SAXException Implements org. Doc from org. Report the beginning of some internal and external XML entities. The reporting of parameter entities (including
the external DTD subset) is optional, and SAX2 drivers that
report LexicalHandler events may not implement it; you can use the
General entities are reported with their regular names, parameter entities have '%' prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]". When a SAX2 driver is providing these events, all other
events must be properly nested within start/end entity
events. There is no additional requirement that events from
Note that skipped entities will be reported through the
Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:
These will be silently expanded, with no indication of where the original entity boundaries were. Note also that the boundaries of character references (which are not really entities anyway) are not reported. All start/endEntity events must be properly nested.
| |
| startPrefixMapping | back to summary |
|---|---|
| public void startPrefixMapping(String prefix, String uri) throws SAXException Overrides org. Implements org. Doc from org. Receive notification of the start of a Namespace mapping. By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each Namespace prefix scope (such as storing the prefix mapping).
| |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| protected byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| protected List | |
| pack-priv static final byte | |
| public static final long | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte | |
| pack-priv static final byte |
| Access | Constructor and Description |
|---|---|
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| pack-priv Object | |
| public void | readExternal(ObjectInput
the stream to read data from in order to restore the object in)Implements java. |
| public void | writeExternal(ObjectOutput
the stream to write the object to out)Implements java. |
| ATTRIBUTE_DECL | back to summary |
|---|---|
| pack-priv static final byte ATTRIBUTE_DECL | |
| CHARACTERS | back to summary |
|---|---|
| pack-priv static final byte CHARACTERS | |
| COMMENT | back to summary |
|---|---|
| pack-priv static final byte COMMENT | |
| ELEMENT_DECL | back to summary |
|---|---|
| pack-priv static final byte ELEMENT_DECL | |
| END_CDATA | back to summary |
|---|---|
| pack-priv static final byte END_CDATA | |
| END_DOCUMENT | back to summary |
|---|---|
| pack-priv static final byte END_DOCUMENT | |
| END_DTD | back to summary |
|---|---|
| pack-priv static final byte END_DTD | |
| END_ELEMENT | back to summary |
|---|---|
| pack-priv static final byte END_ELEMENT | |
| END_ENTITY | back to summary |
|---|---|
| pack-priv static final byte END_ENTITY | |
| END_PREFIX_MAPPING | back to summary |
|---|---|
| pack-priv static final byte END_PREFIX_MAPPING | |
| event | back to summary |
|---|---|
| protected byte event | |
| EXTERNAL_ENTITY_DECL | back to summary |
|---|---|
| pack-priv static final byte EXTERNAL_ENTITY_DECL | |
| INTERNAL_ENTITY_DECL | back to summary |
|---|---|
| pack-priv static final byte INTERNAL_ENTITY_DECL | |
| parms | back to summary |
|---|---|
| protected List<Object> parms | |
| PROCESSING_INSTRUCTION | back to summary |
|---|---|
| pack-priv static final byte PROCESSING_INSTRUCTION | |
| serialVersionUID | back to summary |
|---|---|
| public static final long serialVersionUID | |
| START_CDATA | back to summary |
|---|---|
| pack-priv static final byte START_CDATA | |
| START_DOCUMENT | back to summary |
|---|---|
| pack-priv static final byte START_DOCUMENT | |
| START_DTD | back to summary |
|---|---|
| pack-priv static final byte START_DTD | |
| START_ELEMENT | back to summary |
|---|---|
| pack-priv static final byte START_ELEMENT | |
| START_ENTITY | back to summary |
|---|---|
| pack-priv static final byte START_ENTITY | |
| START_PREFIX_MAPPING | back to summary |
|---|---|
| pack-priv static final byte START_PREFIX_MAPPING | |
| SAXEvent | back to summary |
|---|---|
| public SAXEvent() | |
| SAXEvent | back to summary |
|---|---|
| pack-priv SAXEvent(byte event) | |
| addParm | back to summary |
|---|---|
| pack-priv void addParm(Object parm) | |
| getParm | back to summary |
|---|---|
| pack-priv Object getParm(int index) | |
| readExternal | back to summary |
|---|---|
| public void readExternal(ObjectInput in) throws ClassNotFoundException, IOException Implements java. Doc from java. The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.
| |
| writeExternal | back to summary |
|---|---|
| public void writeExternal(ObjectOutput out) throws IOException Implements java. Doc from java. The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.
| |