public class ParserAdapter extends Object implements XMLReader, DocumentHandler
Adapt a SAX1 Parser as a SAX2 XMLReader.
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
This class wraps a SAX1 Parser
and makes it act as a SAX2 XMLReader
, with feature, property, and Namespace support. Note that it is not possible to report skippedEntity
events, since SAX1 does not make that information available.
This adapter does not test for duplicate Namespace-qualified attribute names.
XMLReaderAdapter
, XMLReader
, Parser
public ParserAdapter() throws SAXException
Construct a new parser adapter.
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.public ParserAdapter(Parser parser)
Construct a new parser adapter.
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.NullPointerException
- If the parser parameter is null.public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
Set a feature flag for the parser.
The only features recognized are namespaces and namespace-prefixes.
setFeature
in interface XMLReader
name
- The feature name, as a complete URI.value
- The requested feature value.SAXNotRecognizedException
- If the feature can't be assigned or retrieved.SAXNotSupportedException
- If the feature can't be assigned that value.XMLReader.setFeature(java.lang.String, boolean)
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException
Check a parser feature flag.
The only features recognized are namespaces and namespace-prefixes.
getFeature
in interface XMLReader
name
- The feature name, as a complete URI.SAXNotRecognizedException
- If the feature value can't be assigned or retrieved.SAXNotSupportedException
- If the feature is not currently readable.XMLReader.setFeature(java.lang.String, boolean)
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
Set a parser property.
No properties are currently recognized.
setProperty
in interface XMLReader
name
- The property name.value
- The property value.SAXNotRecognizedException
- If the property value can't be assigned or retrieved.SAXNotSupportedException
- If the property can't be assigned that value.XMLReader.setProperty(java.lang.String, java.lang.Object)
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
Get a parser property.
No properties are currently recognized.
getProperty
in interface XMLReader
name
- The property name.SAXNotRecognizedException
- If the property value can't be assigned or retrieved.SAXNotSupportedException
- If the property value is not currently readable.XMLReader.getProperty(java.lang.String)
public void setEntityResolver(EntityResolver resolver)
Set the entity resolver.
setEntityResolver
in interface XMLReader
resolver
- The new entity resolver.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public EntityResolver getEntityResolver()
Return the current entity resolver.
getEntityResolver
in interface XMLReader
XMLReader.getEntityResolver()
public void setDTDHandler(DTDHandler handler)
Set the DTD handler.
setDTDHandler
in interface XMLReader
handler
- the new DTD handlerXMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public DTDHandler getDTDHandler()
Return the current DTD handler.
getDTDHandler
in interface XMLReader
XMLReader.getEntityResolver()
public void setContentHandler(ContentHandler handler)
Set the content handler.
setContentHandler
in interface XMLReader
handler
- the new content handlerXMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public ContentHandler getContentHandler()
Return the current content handler.
getContentHandler
in interface XMLReader
XMLReader.getEntityResolver()
public void setErrorHandler(ErrorHandler handler)
Set the error handler.
setErrorHandler
in interface XMLReader
handler
- The new error handler.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public ErrorHandler getErrorHandler()
Return the current error handler.
getErrorHandler
in interface XMLReader
XMLReader.getEntityResolver()
public void parse(String systemId) throws IOException, SAXException
Parse an XML document.
parse
in interface XMLReader
systemId
- The absolute URL of the document.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 void parse(InputSource input) throws IOException, SAXException
Parse an XML document.
parse
in interface XMLReader
input
- An input source for the document.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 void setDocumentLocator(Locator locator)
Adapter implementation method; do not call. Adapt a SAX1 document locator event.
setDocumentLocator
in interface DocumentHandler
locator
- A document locator.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public void startDocument() throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 start document event.
startDocument
in interface DocumentHandler
SAXException
- The client may raise a processing exception.DocumentHandler.startDocument()
public void endDocument() throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 end document event.
endDocument
in interface DocumentHandler
SAXException
- The client may raise a processing exception.DocumentHandler.endDocument()
public void startElement(String qName, AttributeList qAtts) throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 startElement event.
If necessary, perform Namespace processing.
startElement
in interface DocumentHandler
qName
- The qualified (prefixed) name.qAtts
- The XML attribute list (with qnames).SAXException
- The client may raise a processing exception.DocumentHandler.endElement(java.lang.String)
, AttributeList
public void endElement(String qName) throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 end element event.
endElement
in interface DocumentHandler
qName
- The qualified (prefixed) name.SAXException
- The client may raise a processing exception.DocumentHandler.endElement(java.lang.String)
public void characters(char[] ch, int start, int length) throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 characters event.
characters
in interface DocumentHandler
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 void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 ignorable whitespace event.
ignorableWhitespace
in interface DocumentHandler
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 void processingInstruction(String target, String data) throws SAXException
Adapter implementation method; do not call. Adapt a SAX1 processing instruction event.
processingInstruction
in interface DocumentHandler
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)
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.