public class ParserAdapter extends java.lang.Object implements org.xml.sax.XMLReader, org.xml.sax.DocumentHandler
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| Constructor and Description |
|---|
ParserAdapter()
Construct a new parser adapter.
|
ParserAdapter(org.xml.sax.Parser parser)
Construct a new parser adapter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Adapter implementation method; do not call.
|
void |
endDocument()
Adapter implementation method; do not call.
|
void |
endElement(java.lang.String qName)
Adapter implementation method; do not call.
|
org.xml.sax.ContentHandler |
getContentHandler()
Return the current content handler.
|
org.xml.sax.DTDHandler |
getDTDHandler()
Return the current DTD handler.
|
org.xml.sax.EntityResolver |
getEntityResolver()
Return the current entity resolver.
|
org.xml.sax.ErrorHandler |
getErrorHandler()
Return the current error handler.
|
boolean |
getFeature(java.lang.String name)
Check a parser feature flag.
|
java.lang.Object |
getProperty(java.lang.String name)
Get a parser property.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Adapter implementation method; do not call.
|
void |
parse(org.xml.sax.InputSource input)
Parse an XML document.
|
void |
parse(java.lang.String systemId)
Parse an XML document.
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Adapter implementation method; do not call.
|
void |
setContentHandler(org.xml.sax.ContentHandler handler)
Set the content handler.
|
void |
setDocumentLocator(org.xml.sax.Locator locator)
Adapter implementation method; do not call.
|
void |
setDTDHandler(org.xml.sax.DTDHandler handler)
Set the DTD handler.
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Set the entity resolver.
|
void |
setErrorHandler(org.xml.sax.ErrorHandler handler)
Set the error handler.
|
void |
setFeature(java.lang.String name,
boolean value)
Set a feature flag for the parser.
|
void |
setProperty(java.lang.String name,
java.lang.Object value)
Set a parser property.
|
void |
startDocument()
Adapter implementation method; do not call.
|
void |
startElement(java.lang.String qName,
org.xml.sax.AttributeList qAtts)
Adapter implementation method; do not call.
|
public ParserAdapter() throws org.xml.sax.SAXException
Use the "org.xml.sax.parser" property to locate the embedded SAX1 driver.
org.xml.sax.SAXException - If the embedded driver
cannot be instantiated or if the
org.xml.sax.parser property is not specified.public ParserAdapter(org.xml.sax.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 void setFeature(java.lang.String name, boolean value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
The only features recognized are namespaces and namespace-prefixes.
setFeature in interface org.xml.sax.XMLReadername - The feature name, as a complete URI.value - The requested feature value.org.xml.sax.SAXNotRecognizedException - If the feature
can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException - If the feature
can't be assigned that value.XMLReader.setFeature(java.lang.String, boolean)public boolean getFeature(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
The only features recognized are namespaces and namespace-prefixes.
getFeature in interface org.xml.sax.XMLReadername - The feature name, as a complete URI.org.xml.sax.SAXNotRecognizedException - If the feature
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException - If the
feature is not currently readable.XMLReader.setFeature(java.lang.String, boolean)public void setProperty(java.lang.String name, java.lang.Object value) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
No properties are currently recognized.
setProperty in interface org.xml.sax.XMLReadername - The property name.value - The property value.org.xml.sax.SAXNotRecognizedException - If the property
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException - If the property
can't be assigned that value.XMLReader.setProperty(java.lang.String, java.lang.Object)public java.lang.Object getProperty(java.lang.String name) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException
No properties are currently recognized.
getProperty in interface org.xml.sax.XMLReadername - The property name.org.xml.sax.SAXNotRecognizedException - If the property
value can't be assigned or retrieved.org.xml.sax.SAXNotSupportedException - If the property
value is not currently readable.XMLReader.getProperty(java.lang.String)public void setEntityResolver(org.xml.sax.EntityResolver resolver)
setEntityResolver in interface org.xml.sax.XMLReaderresolver - The new entity resolver.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)public org.xml.sax.EntityResolver getEntityResolver()
getEntityResolver in interface org.xml.sax.XMLReaderXMLReader.getEntityResolver()public void setDTDHandler(org.xml.sax.DTDHandler handler)
setDTDHandler in interface org.xml.sax.XMLReaderhandler - the new DTD handlerXMLReader.setEntityResolver(org.xml.sax.EntityResolver)public org.xml.sax.DTDHandler getDTDHandler()
getDTDHandler in interface org.xml.sax.XMLReaderXMLReader.getEntityResolver()public void setContentHandler(org.xml.sax.ContentHandler handler)
setContentHandler in interface org.xml.sax.XMLReaderhandler - the new content handlerXMLReader.setEntityResolver(org.xml.sax.EntityResolver)public org.xml.sax.ContentHandler getContentHandler()
getContentHandler in interface org.xml.sax.XMLReaderXMLReader.getEntityResolver()public void setErrorHandler(org.xml.sax.ErrorHandler handler)
setErrorHandler in interface org.xml.sax.XMLReaderhandler - The new error handler.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)public org.xml.sax.ErrorHandler getErrorHandler()
getErrorHandler in interface org.xml.sax.XMLReaderXMLReader.getEntityResolver()public void parse(java.lang.String systemId) throws java.io.IOException, org.xml.sax.SAXException
parse in interface org.xml.sax.XMLReadersystemId - The absolute URL of the document.java.io.IOException - If there is a problem reading
the raw content of the document.org.xml.sax.SAXException - If there is a problem
processing the document.parse(org.xml.sax.InputSource),
Parser.parse(java.lang.String)public void parse(org.xml.sax.InputSource input) throws java.io.IOException, org.xml.sax.SAXException
parse in interface org.xml.sax.XMLReaderinput - An input source for the document.java.io.IOException - If there is a problem reading
the raw content of the document.org.xml.sax.SAXException - If there is a problem
processing the document.parse(java.lang.String),
Parser.parse(org.xml.sax.InputSource)public void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator in interface org.xml.sax.DocumentHandlerlocator - A document locator.ContentHandler.setDocumentLocator(org.xml.sax.Locator)public void startDocument() throws org.xml.sax.SAXException
startDocument in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.startDocument()public void endDocument() throws org.xml.sax.SAXException
endDocument in interface org.xml.sax.DocumentHandlerorg.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.endDocument()public void startElement(java.lang.String qName, org.xml.sax.AttributeList qAtts) throws org.xml.sax.SAXException
If necessary, perform Namespace processing.
startElement in interface org.xml.sax.DocumentHandlerqName - The qualified (prefixed) name.qAtts - The XML attribute list (with qnames).org.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.endElement(java.lang.String),
AttributeListpublic void endElement(java.lang.String qName) throws org.xml.sax.SAXException
endElement in interface org.xml.sax.DocumentHandlerqName - The qualified (prefixed) name.org.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.endElement(java.lang.String)public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters in interface org.xml.sax.DocumentHandlerch - An array of characters.start - The starting position in the array.length - The number of characters to use.org.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.characters(char[], int, int)public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace in interface org.xml.sax.DocumentHandlerch - An array of characters.start - The starting position in the array.length - The number of characters to use.org.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.ignorableWhitespace(char[], int, int)public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.DocumentHandlertarget - The processing instruction target.data - The remainder of the processing instructionorg.xml.sax.SAXException - The client may raise a
processing exception.DocumentHandler.processingInstruction(java.lang.String, java.lang.String)