H - the type of handler to which this parser sends eventspublic abstract class XMLParser<H extends Handler> extends InputSourceParser<H>
XMLParser adapts a handler to be used to handle
text extracted from an XML source. The parser implements parse(InputSource) using an XMLReader and an DefaultHandler that is constructed by means of the abstract method
getXMLHandler(). The parsing method traps
thrown instances of SAXException and converts them to instances of
IOException before rethrowing them in order to confrom to
the specification of Parser.parse(InputSource).| Constructor and Description |
|---|
XMLParser()
Construct an XML parser with a
null handler. |
XMLParser(H handler)
Construct an XML parser with the specified handler.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract org.xml.sax.helpers.DefaultHandler |
getXMLHandler()
Return the default handler for SAX events.
|
void |
parse(InputSource inSource)
Parse the specified input source.
|
parseStringgetHandler, parse, parse, parse, parse, parseString, setHandlerpublic XMLParser()
null handler.public XMLParser(H handler)
handler - Handler to use for parsing.protected abstract org.xml.sax.helpers.DefaultHandler getXMLHandler()
Handler specified for this
class and pass events to it extracted from the XML. Typical
concrete implementations of this method will extract the underlying
handler using Parser.getHandler() and wrap it in a default
handler.
This method is called exactly once in each parse method in this class. Thus dynamic updates to the underlying handler may be picked up by this adapter method.
public void parse(InputSource inSource) throws IOException
getXMLHandler()
method as the handler for SAX events generated by parsing
the specified input source.
All SAX exceptions thrown by XML parsing are converted to I/O exceptions and rethrown; this step is required by the parent class's specification of this method.
parse in class Parser<H extends Handler>inSource - Input source to parse.IOException - If there is an I/O exception or a SAX
exception raised while parsing.Copyright © 2016 Alias-i, Inc.. All rights reserved.