public class FilteredSaxHandler
extends org.jdom.input.SAXHandler
FastSaxBuilder
by overriding FastSaxBuilder.createContentHandler().| Modifier and Type | Class and Description |
|---|---|
static interface |
FilteredSaxHandler.ElementHandler |
| Constructor and Description |
|---|
FilteredSaxHandler(List<String> elementNamesToMatch,
FilteredSaxHandler.ElementHandler elementHandler,
long maximumExpectedSize)
Creates a sax handler that provides elements matching a given name pattern to a callback.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
clearTextBufferCache() |
void |
endElement(String namespace,
String localName,
String qName) |
protected void |
flushCharacters() |
protected void |
flushCharactersAtElementEnd() |
void |
setIgnoreBoundaryWhitespaceWithSiblings(boolean ignoringWhiteWithSiblings)
Similar to
SAXHandler.setIgnoringBoundaryWhitespace(boolean)
except that we only eliminate text nodes that have siblings. |
void |
startElement(String namespace,
String localName,
String qName,
Attributes attributes) |
attributeDecl, comment, elementDecl, endCDATA, endDTD, endEntity, externalEntityDecl, flushCharacters, getCurrentElement, getDocument, getDocumentLocator, getExpandEntities, getFactory, getIgnoringBoundaryWhitespace, getIgnoringElementContentWhitespace, ignorableWhitespace, internalEntityDecl, notationDecl, processingInstruction, pushElement, setDocumentLocator, setExpandEntities, setIgnoringBoundaryWhitespace, setIgnoringElementContentWhitespace, skippedEntity, startCDATA, startDocument, startDTD, startEntity, startPrefixMapping, unparsedEntityDeclendDocument, endPrefixMapping, error, fatalError, resolveEntity, warningpublic FilteredSaxHandler(List<String> elementNamesToMatch, FilteredSaxHandler.ElementHandler elementHandler, long maximumExpectedSize)
elementNamesToMatch - the names of elements to report to elementHandler. These are slash (/) separated element names where * represents any element name. e.g. "rootElementName/childElementName" or "rootElementName/*"elementHandler - a callback to report all elements matching elementNamesToMatch are reported to. The matching elements will be detached from their parent element, allowing parsing of XML files that are too large to fit in memory.maximumExpectedSize - the maximum size in bytes of the data that will be read from the input stream. This is used to allocate more appropriate buffer sizes and hence reduce memory usage and increase speed. This may be <=0 in which case performance and memory usage may not be as good.public void startElement(String namespace, String localName, String qName, Attributes attributes) throws SAXException
startElement in interface ContentHandlerstartElement in class org.jdom.input.SAXHandlerSAXExceptionpublic void endElement(String namespace, String localName, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class org.jdom.input.SAXHandlerSAXExceptionpublic void setIgnoreBoundaryWhitespaceWithSiblings(boolean ignoringWhiteWithSiblings)
SAXHandler.setIgnoringBoundaryWhitespace(boolean)
except that we only eliminate text nodes that have siblings.
e.g.
<x><y> </y></x> will preserve the space text in y.<x><y> <z></z></y></x> will not preserve the space text in y which is a sibling to "z".ignoringWhiteWithSiblings - Whether to ignore only whitespace contentpublic void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class org.jdom.input.SAXHandlerSAXExceptionprotected void flushCharacters()
throws SAXException
flushCharacters in class org.jdom.input.SAXHandlerSAXExceptionprotected void flushCharactersAtElementEnd()
throws SAXException
flushCharactersAtElementEnd in class org.jdom.input.SAXHandlerSAXExceptionpublic void clearTextBufferCache()