public abstract class AbstractXmlParser
extends org.xml.sax.helpers.DefaultHandler
Constructor and Description |
---|
AbstractXmlParser() |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
Handle multiple callbacks per element, which will happen when the data
includes xml escape sequences.
|
void |
collectCharacters(java.lang.String expectedElement)
Inform the parser that we want to start gathering up the character data
for the current element.
|
java.lang.String |
getCollectedCharacters(java.lang.String expectedElement)
Get the final string accumulated from all invocations of
characters(char[], int, int) since the last call to collectCharacters(java.lang.String) . |
boolean |
parseXmlResource(java.io.File file)
Parse an XML resource by url.
|
boolean |
parseXmlResource(java.lang.Object resourceName,
org.xml.sax.InputSource source)
Parse from the given source.
|
endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
public boolean parseXmlResource(java.io.File file)
file
- The file to parse.public boolean parseXmlResource(java.lang.Object resourceName, org.xml.sax.InputSource source)
resourceName
- The resource name to use in warning messages.source
- The source of the xml input.public void collectCharacters(java.lang.String expectedElement)
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
with the localName as the parameter.
Use getCollectedCharacters(java.lang.String)
, typically in the corresponding
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
, to retrieve the result.expectedElement
- The element whose character data we're gathering.
Caller must pass the same element to
getCollectedCharacters(java.lang.String)
to ensure consistency.public java.lang.String getCollectedCharacters(java.lang.String expectedElement)
characters(char[], int, int)
since the last call to collectCharacters(java.lang.String)
.expectedElement
- The element whose character data we're gathering.
Caller must pass the same element to collectCharacters(java.lang.String)
to
ensure consistency.characters(char[], int, int)
.java.lang.RuntimeException
- if the expectedElement doesn't match.public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details