java.lang.Object | +--org.xml.sax.helpers.ParserAdapter
Adapt a SAX1 Parser as a SAX2 XMLReader.
This module, both source code and documentation, is in the Public Domain, and comes withNO WARRANTY.
This class wraps a SAX1Parser
and makes it act as a SAX2XMLReader
, with feature, property, and Namespace support. Note that it is not possible to reportskippedEntity
events, since SAX1 does not make that information available.
This adapter does not test for duplicate Namespace-qualified attribute names.
XMLReaderAdapter
,XMLReader
,Parser
ParserAdapter() Construct a new parser adapter. | |
ParserAdapter(Parser parser) Construct a new parser adapter. |
characters(char[] ch, int start, int length) Adapt a SAX1 characters event. | |
endDocument() Adapt a SAX1 end document event. | |
endElement(java.lang.String qName) Adapt a SAX1 end element event. | |
getContentHandler() Return the current content handler. | |
getDTDHandler() Return the current DTD handler. | |
getEntityResolver() Return the current entity resolver. | |
getErrorHandler() Return the current error handler. | |
getFeature(java.lang.String name) Check a parser feature. | |
getProperty(java.lang.String name) Get a parser property. | |
ignorableWhitespace(char[] ch, int start, int length) Adapt a SAX1 ignorable whitespace event. | |
parse(InputSource input) Parse an XML document. | |
parse(java.lang.String systemId) Parse an XML document. | |
processingInstruction(java.lang.String target, java.lang.String data) Adapt a SAX1 processing instruction event. | |
setContentHandler(ContentHandler handler) Set the content handler. | |
setDocumentLocator(Locator locator) Adapt a SAX1 document locator event. | |
setDTDHandler(DTDHandler handler) Set the DTD handler. | |
setEntityResolver(EntityResolver resolver) Set the entity resolver. | |
setErrorHandler(ErrorHandler handler) Set the error handler. | |
setFeature(java.lang.String name, boolean state) Set a feature for the parser. | |
setProperty(java.lang.String name, java.lang.Object value) Set a parser property. | |
startDocument() Adapt a SAX1 start document event. | |
startElement(java.lang.String qName,AttributeList qAtts) Adapt a SAX1 startElement event. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
publicParserAdapter() throwsSAXException
Use the "org.xml.sax.parser" property to locate the embedded SAX1 driver.
SAXException
- If the embedded driver cannot be instantiated or if the org.xml.sax.parser property is not specified.publicParserAdapter(Parser parser)
Note that the embedded parser cannot be changed once the adapter is created; to embed a different parser, allocate a new ParserAdapter.
parser
- The SAX1 parser to embed.java.lang.NullPointerException
- If the parser parameter is null.public voidsetFeature(java.lang.String name, boolean state) throwsSAXNotRecognizedException,SAXNotSupportedException
The only features supported are namespaces and namespace-prefixes.
setFeature
in interfaceXMLReader
name
- The feature name, as a complete URI.state
- The requested feature state.SAXNotRecognizedException
- If the feature name is not known.SAXNotSupportedException
- If the feature state is not supported.XMLReader.setFeature(java.lang.String, boolean)
public booleangetFeature(java.lang.String name) throwsSAXNotRecognizedException,SAXNotSupportedException
The only features supported are namespaces and namespace-prefixes.
getFeature
in interfaceXMLReader
name
- The feature name, as a complete URI.SAXNotRecognizedException
- If the feature name is not known.SAXNotSupportedException
- If querying the feature state is not supported.XMLReader.setFeature(java.lang.String, boolean)
public voidsetProperty(java.lang.String name, java.lang.Object value) throwsSAXNotRecognizedException,SAXNotSupportedException
No special properties are currently supported.
setProperty
in interfaceXMLReader
name
- The property name.value
- The property value.SAXNotRecognizedException
- If the feature name is not known.SAXNotSupportedException
- If the feature state is not supported.XMLReader.setProperty(java.lang.String, java.lang.Object)
public java.lang.ObjectgetProperty(java.lang.String name) throwsSAXNotRecognizedException,SAXNotSupportedException
No special properties are currently supported.
getProperty
in interfaceXMLReader
name
- The property name.SAXNotRecognizedException
- If the feature name is not known.SAXNotSupportedException
- If the feature state is not supported.XMLReader.getProperty(java.lang.String)
public voidsetEntityResolver(EntityResolver resolver)
setEntityResolver
in interfaceXMLReader
resolver
- The new entity resolver.java.lang.NullPointerException
- If the entity resolver parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
publicEntityResolvergetEntityResolver()
getEntityResolver
in interfaceXMLReader
XMLReader.getEntityResolver()
public voidsetDTDHandler(DTDHandler handler)
setDTDHandler
in interfaceXMLReader
resolver
- The new DTD handler.java.lang.NullPointerException
- If the DTD handler parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
publicDTDHandlergetDTDHandler()
getDTDHandler
in interfaceXMLReader
XMLReader.getEntityResolver()
public voidsetContentHandler(ContentHandler handler)
setContentHandler
in interfaceXMLReader
resolver
- The new content handler.java.lang.NullPointerException
- If the content handler parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
publicContentHandlergetContentHandler()
getContentHandler
in interfaceXMLReader
XMLReader.getEntityResolver()
public voidsetErrorHandler(ErrorHandler handler)
setErrorHandler
in interfaceXMLReader
resolver
- The new error handler.java.lang.NullPointerException
- If the error handler parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
publicErrorHandlergetErrorHandler()
getErrorHandler
in interfaceXMLReader
XMLReader.getEntityResolver()
public voidparse(java.lang.String systemId) throws java.io.IOException,SAXException
parse
in interfaceXMLReader
systemId
- The absolute URL of the document.java.io.IOException
- If there is a problem reading the raw content of the document.SAXException
- If there is a problem processing the document.parse(org.xml.sax.InputSource)
,Parser.parse(java.lang.String)
public voidparse(InputSource input) throws java.io.IOException,SAXException
parse
in interfaceXMLReader
input
- An input source for the document.java.io.IOException
- If there is a problem reading the raw content of the document.SAXException
- If there is a problem processing the document.parse(java.lang.String)
,Parser.parse(org.xml.sax.InputSource)
public voidsetDocumentLocator(Locator locator)
setDocumentLocator
in interfaceDocumentHandler
locator
- A document locator.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public voidstartDocument() throwsSAXException
startDocument
in interfaceDocumentHandler
SAXException
- The client may raise a processing exception.DocumentHandler.startDocument()
public voidendDocument() throwsSAXException
endDocument
in interfaceDocumentHandler
SAXException
- The client may raise a processing exception.DocumentHandler.endDocument()
public voidstartElement(java.lang.String qName,AttributeList qAtts) throwsSAXException
If necessary, perform Namespace processing.
startElement
in interfaceDocumentHandler
qName
- The qualified (prefixed) name.qAtts
- The XML 1.0 attribute list (with qnames).public voidendElement(java.lang.String qName) throwsSAXException
endElement
in interfaceDocumentHandler
qName
- The qualified (prefixed) name.SAXException
- The client may raise a processing exception.DocumentHandler.endElement(java.lang.String)
public voidcharacters(char[] ch, int start, int length) throwsSAXException
characters
in interfaceDocumentHandler
ch
- An array of characters.start
- The starting position in the array.length
- The number of characters to use.SAXException
- The client may raise a processing exception.DocumentHandler.characters(char[], int, int)
public voidignorableWhitespace(char[] ch, int start, int length) throwsSAXException
ignorableWhitespace
in interfaceDocumentHandler
ch
- An array of characters.start
- The starting position in the array.length
- The number of characters to use.SAXException
- The client may raise a processing exception.DocumentHandler.ignorableWhitespace(char[], int, int)
public voidprocessingInstruction(java.lang.String target, java.lang.String data) throwsSAXException
processingInstruction
in interfaceDocumentHandler
target
- The processing instruction target.data
- The remainder of the processing instructionSAXException
- The client may raise a processing exception.DocumentHandler.processingInstruction(java.lang.String, java.lang.String)