| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 {@link org.xml.sax.Parser Parser} and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader}, with feature, property, and Namespace support. Note that it is not possible to report {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity} events, since SAX1 does not make that information available.
This adapter does not test for duplicate Namespace-qualified attribute names.
Constructor Summary | |
---|---|
Construct a new parser adapter. |
|
ParserAdapter(Parser parser) Construct a new parser adapter. |
Method Summary | |
---|---|
void |
characters(char[] ch, int start, int length) Adapter implementation method; do not call. |
void |
Adapter implementation method; do not call. |
void |
endElement(String qName) Adapter implementation method; do not call. |
ContentHandler |
Return the current content handler. |
DTDHandler |
Return the current DTD handler. |
EntityResolver |
Return the current entity resolver. |
ErrorHandler |
Return the current error handler. |
boolean |
getFeature(String name) Check a parser feature flag. |
Object |
getProperty(String name) Get a parser property. |
void |
ignorableWhitespace(char[] ch, int start, int length) Adapter implementation method; do not call. |
void |
parse(InputSource input) Parse an XML document. |
void |
Parse an XML document. |
void |
processingInstruction(String target, String data) Adapter implementation method; do not call. |
void |
setContentHandler(ContentHandler handler) Set the content handler. |
void |
setDocumentLocator(Locator locator) Adapter implementation method; do not call. |
void |
setDTDHandler(DTDHandler handler) Set the DTD handler. |
void |
setEntityResolver(EntityResolver resolver) Set the entity resolver. |
void |
setErrorHandler(ErrorHandler handler) Set the error handler. |
void |
setFeature(String name, boolean value) Set a feature flag for the parser. |
void |
setProperty(String name, Object value) Set a parser property. |
void |
Adapter implementation method; do not call. |
void |
startElement(String qName, AttributeList qAtts) Adapter implementation method; do not call. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParserAdapter() throws SAXException
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)
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.Method Detail |
---|
public void characters(char[] ch, int start, int length) throws SAXException
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.public void endDocument() throws SAXException
SAXException
- The client may raise a
processing exception.public void endElement(String qName) throws SAXException
qName
- The qualified (prefixed) name.SAXException
- The client may raise a
processing exception.public ContentHandler getContentHandler()
public DTDHandler getDTDHandler()
public EntityResolver getEntityResolver()
public ErrorHandler getErrorHandler()
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException
The only features recognized are namespaces and namespace-prefixes.
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.public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
No properties are currently recognized.
name
- The property name.SAXNotRecognizedException
- If the property
value can't be assigned or retrieved.SAXNotSupportedException
- If the property
value is not currently readable.public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
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.public void parse(InputSource input) throws IOException, SAXException
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.public void parse(String systemId) throws IOException, SAXException
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.public void processingInstruction(String target, String data) throws SAXException
target
- The processing instruction target.data
- The remainder of the processing instructionSAXException
- The client may raise a
processing exception.public void setContentHandler(ContentHandler handler)
handler
- the new content handlerpublic void setDocumentLocator(Locator locator)
locator
- A document locator.public void setDTDHandler(DTDHandler handler)
handler
- the new DTD handlerpublic void setEntityResolver(EntityResolver resolver)
resolver
- The new entity resolver.public void setErrorHandler(ErrorHandler handler)
handler
- The new error handler.public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
The only features recognized are namespaces and namespace-prefixes.
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.public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
No properties are currently recognized.
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.public void startDocument() throws SAXException
SAXException
- The client may raise a
processing exception.public void startElement(String qName, AttributeList qAtts) throws SAXException
If necessary, perform Namespace processing.
qName
- The qualified (prefixed) name.qAtts
- The XML attribute list (with qnames).SAXException
- The client may raise a
processing exception.
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |