SAX2EventRecorderpublic class SAX2EventRecorder extends Object This class records SAX2 Events and allows
the events to be replayed by start and stop index |
Fields Summary |
---|
private static final Integer | Z | private static final Integer | STATE_SET_DOCUMENT_LOCATOR | private static final Integer | STATE_START_DOCUMENT | private static final Integer | STATE_END_DOCUMENT | private static final Integer | STATE_START_PREFIX_MAPPING | private static final Integer | STATE_END_PREFIX_MAPPING | private static final Integer | STATE_START_ELEMENT | private static final Integer | STATE_END_ELEMENT | private static final Integer | STATE_CHARACTERS | private static final Integer | STATE_IGNORABLE_WHITESPACE | private static final Integer | STATE_PROCESSING_INSTRUCTION | private static final Integer | STATE_SKIPPED_ENTITY | private static final Integer | STATE_NEWELEMENT | private static final Integer | STATE_START_DTD | private static final Integer | STATE_END_DTD | private static final Integer | STATE_START_ENTITY | private static final Integer | STATE_END_ENTITY | private static final Integer | STATE_START_CDATA | private static final Integer | STATE_END_CDATA | private static final Integer | STATE_COMMENT | Locator | locator | objArrayVector | events |
Methods Summary |
---|
public int | characters(char[] p1, int p2, int p3)
return events.add(STATE_CHARACTERS,
(Object)clone(p1, p2, p3),
Z, Z, Z);
| public void | clear()
locator = null;
events = new objArrayVector();
| private static char[] | clone(char[] in, int off, int len)
char[] out = new char[len];
System.arraycopy(in, off, out, 0, len);
return out;
| public void | comment(char[] ch, int start, int length)
events.add(STATE_COMMENT,
(Object)clone(ch, start, length),
Z, Z, Z);
| public void | endCDATA()
events.add(STATE_END_CDATA, Z, Z, Z, Z);
| public void | endDTD()
events.add(STATE_END_DTD, Z, Z, Z, Z);
| public int | endDocument()
return events.add(STATE_END_DOCUMENT, Z,Z,Z,Z);
| public int | endElement(java.lang.String p1, java.lang.String p2, java.lang.String p3)
return events.add(STATE_END_ELEMENT, p1, p2, p3, Z);
| public void | endEntity(java.lang.String name)
events.add(STATE_END_ENTITY, name, Z, Z, Z);
| public int | endPrefixMapping(java.lang.String p1)
return events.add(STATE_END_PREFIX_MAPPING, p1,Z,Z,Z);
| public int | getLength()
return events.getLength();
| public int | ignorableWhitespace(char[] p1, int p2, int p3)
return events.add(STATE_IGNORABLE_WHITESPACE,
(Object)clone(p1, p2, p3),
Z, Z, Z);
| public int | newElement(MessageElement elem)
return events.add(STATE_NEWELEMENT, elem, Z,Z,Z);
| public int | processingInstruction(java.lang.String p1, java.lang.String p2)
return events.add(STATE_PROCESSING_INSTRUCTION, p1, p2, Z,Z);
| public void | replay(org.xml.sax.ContentHandler handler)
if (events.getLength() > 0) {
replay(0, events.getLength() - 1, handler);
}
| public void | replay(int start, int stop, org.xml.sax.ContentHandler handler)
// Special case : play the whole thing for [0, -1]
if ((start == 0) && (stop == -1)) {
replay(handler);
return;
}
if (stop + 1 > events.getLength() ||
stop < start) {
return; // should throw an error here
}
LexicalHandler lexicalHandler = null;
if (handler instanceof LexicalHandler) {
lexicalHandler = (LexicalHandler) handler;
}
for (int n = start; n <= stop; n++) {
Object event = events.get(n,0);
if (event == STATE_START_ELEMENT) {
handler.startElement((String)events.get(n,1),
(String)events.get(n,2),
(String)events.get(n,3),
(org.xml.sax.Attributes)events.get(n,4));
} else if (event == STATE_END_ELEMENT) {
handler.endElement((String)events.get(n,1),
(String)events.get(n,2),
(String)events.get(n,3));
} else if (event == STATE_CHARACTERS) {
char[] data = (char[])events.get(n,1);
handler.characters(data, 0, data.length);
} else if (event == STATE_IGNORABLE_WHITESPACE) {
char[] data = (char[])events.get(n,1);
handler.ignorableWhitespace(data, 0, data.length);
} else if (event == STATE_PROCESSING_INSTRUCTION) {
handler.processingInstruction((String)events.get(n,1),
(String)events.get(n,2));
} else if (event == STATE_SKIPPED_ENTITY) {
handler.skippedEntity((String)events.get(n,1));
} else if (event == STATE_SET_DOCUMENT_LOCATOR) {
handler.setDocumentLocator(locator);
} else if (event == STATE_START_DOCUMENT) {
handler.startDocument();
} else if (event == STATE_END_DOCUMENT) {
handler.endDocument();
} else if (event == STATE_START_PREFIX_MAPPING) {
handler.startPrefixMapping((String)events.get(n, 1),
(String)events.get(n, 2));
} else if (event == STATE_END_PREFIX_MAPPING) {
handler.endPrefixMapping((String)events.get(n, 1));
} else if (event == STATE_START_DTD && lexicalHandler != null) {
lexicalHandler.startDTD((String)events.get(n,1),
(String)events.get(n,2),
(String)events.get(n,3));
} else if (event == STATE_END_DTD && lexicalHandler != null) {
lexicalHandler.endDTD();
} else if (event == STATE_START_ENTITY && lexicalHandler != null) {
lexicalHandler.startEntity((String)events.get(n,1));
} else if (event == STATE_END_ENTITY && lexicalHandler != null) {
lexicalHandler.endEntity((String)events.get(n,1));
} else if (event == STATE_START_CDATA && lexicalHandler != null) {
lexicalHandler.startCDATA();
} else if (event == STATE_END_CDATA && lexicalHandler != null) {
lexicalHandler.endCDATA();
} else if (event == STATE_COMMENT && lexicalHandler != null) {
char[] data = (char[])events.get(n,1);
lexicalHandler.comment(data, 0, data.length);
} else if (event == STATE_NEWELEMENT) {
if (handler instanceof DeserializationContext) {
DeserializationContext context =
(DeserializationContext)handler;
context.setCurElement(
(MessageElement)(events.get(n,1)));
}
}
}
| public int | setDocumentLocator(org.xml.sax.Locator p1)
locator = p1;
return events.add(STATE_SET_DOCUMENT_LOCATOR, Z,Z,Z,Z);
| public int | skippedEntity(java.lang.String p1)
return events.add(STATE_SKIPPED_ENTITY, p1, Z,Z,Z);
| public void | startCDATA()
events.add(STATE_START_CDATA, Z, Z, Z, Z);
| public void | startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
events.add(STATE_START_DTD, name, publicId, systemId, Z);
| public int | startDocument()
return events.add(STATE_START_DOCUMENT, Z,Z,Z,Z);
| public int | startElement(java.lang.String p1, java.lang.String p2, java.lang.String p3, org.xml.sax.Attributes p4)
return events.add(STATE_START_ELEMENT, p1, p2, p3, p4);
| public void | startEntity(java.lang.String name)
events.add(STATE_START_ENTITY, name, Z, Z, Z);
| public int | startPrefixMapping(java.lang.String p1, java.lang.String p2)
return events.add(STATE_START_PREFIX_MAPPING, p1, p2, Z,Z);
|
|