|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
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 with NO WARRANTY.
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.
Note that this is not the class shipped with SAX 2.0.1; this class takes into account the presence of AccessControllers in J2EE 1.4. It also throws NullPointerExceptions when setters are called with null parameters; the 2.0.1 version does not exhibit this behaviour.
XMLReaderAdapter,
XMLReader,
Parser| Constructor Summary | |
ParserAdapter()
Construct a new parser adapter. |
|
ParserAdapter(Parser parser)
Construct a new parser adapter. |
|
| Method Summary | |
void |
characters(char[] ch,
int start,
int length)
Adapt a SAX1 characters event. |
void |
endDocument()
Adapt a SAX1 end document event. |
void |
endElement(java.lang.String qName)
Adapt a SAX1 end element event. |
ContentHandler |
getContentHandler()
Return the current content handler. |
DTDHandler |
getDTDHandler()
Return the current DTD handler. |
EntityResolver |
getEntityResolver()
Return the current entity resolver. |
ErrorHandler |
getErrorHandler()
Return the current error handler. |
boolean |
getFeature(java.lang.String name)
Check a parser feature. |
java.lang.Object |
getProperty(java.lang.String name)
Get a parser property. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Adapt a SAX1 ignorable whitespace event. |
void |
parse(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)
Adapt a SAX1 processing instruction event. |
void |
setContentHandler(ContentHandler handler)
Set the content handler. |
void |
setDocumentLocator(Locator locator)
Adapt a SAX1 document locator event. |
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(java.lang.String name,
boolean state)
Set a feature for the parser. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Set a parser property. |
void |
startDocument()
Adapt a SAX1 start document event. |
void |
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 |
| 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.java.lang.NullPointerException - If the parser parameter
is null.| Method Detail |
public void setFeature(java.lang.String name,
boolean state)
throws SAXNotRecognizedException,
SAXNotSupportedException
The only features supported are namespaces and namespace-prefixes.
setFeature in interface XMLReadername - 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 boolean getFeature(java.lang.String name)
throws SAXNotRecognizedException,
SAXNotSupportedException
The only features supported are namespaces and namespace-prefixes.
getFeature in interface XMLReadername - 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 void setProperty(java.lang.String name,
java.lang.Object value)
throws SAXNotRecognizedException,
SAXNotSupportedException
No special properties are currently supported.
setProperty in interface XMLReadername - 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.Object getProperty(java.lang.String name)
throws SAXNotRecognizedException,
SAXNotSupportedException
No special properties are currently supported.
getProperty in interface XMLReadername - 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 void setEntityResolver(EntityResolver resolver)
setEntityResolver in interface XMLReaderresolver - The new entity resolver.java.lang.NullPointerException - If the entity resolver
parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)public EntityResolver getEntityResolver()
getEntityResolver in interface XMLReaderXMLReader.getEntityResolver()public void setDTDHandler(DTDHandler handler)
setDTDHandler in interface XMLReaderresolver - The new DTD handler.java.lang.NullPointerException - If the DTD handler
parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)public DTDHandler getDTDHandler()
getDTDHandler in interface XMLReaderXMLReader.getEntityResolver()public void setContentHandler(ContentHandler handler)
setContentHandler in interface XMLReaderresolver - The new content handler.java.lang.NullPointerException - If the content handler
parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)public ContentHandler getContentHandler()
getContentHandler in interface XMLReaderXMLReader.getEntityResolver()public void setErrorHandler(ErrorHandler handler)
setErrorHandler in interface XMLReaderresolver - The new error handler.java.lang.NullPointerException - If the error handler
parameter is null.XMLReader.setEntityResolver(org.xml.sax.EntityResolver)public ErrorHandler getErrorHandler()
getErrorHandler in interface XMLReaderXMLReader.getEntityResolver()
public void parse(java.lang.String systemId)
throws java.io.IOException,
SAXException
parse in interface XMLReadersystemId - 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 void parse(InputSource input)
throws java.io.IOException,
SAXException
parse in interface XMLReaderinput - 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 void setDocumentLocator(Locator locator)
setDocumentLocator in interface DocumentHandlerlocator - A document locator.ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public void startDocument()
throws SAXException
startDocument in interface DocumentHandlerSAXException - The client may raise a
processing exception.DocumentHandler.startDocument()
public void endDocument()
throws SAXException
endDocument in interface DocumentHandlerSAXException - The client may raise a
processing exception.DocumentHandler.endDocument()
public void startElement(java.lang.String qName,
AttributeList qAtts)
throws SAXException
If necessary, perform Namespace processing.
startElement in interface DocumentHandlerqName - The qualified (prefixed) name.qAtts - The XML 1.0 attribute list (with qnames).
public void endElement(java.lang.String qName)
throws SAXException
endElement in interface DocumentHandlerqName - 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
characters in interface DocumentHandlerch - 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
ignorableWhitespace in interface DocumentHandlerch - 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(java.lang.String target,
java.lang.String data)
throws SAXException
processingInstruction in interface DocumentHandlertarget - 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)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||