- java.lang.Object
- 
- org.xml.sax.helpers.ParserAdapter
 
- 
- All Implemented Interfaces:
- DocumentHandler,- XMLReader
 
 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 Parserand makes it act as a SAX2XMLReader, with feature, property, and Namespace support. Note that it is not possible to reportskippedEntityevents, since SAX1 does not make that information available.This adapter does not test for duplicate Namespace-qualified attribute names. - Since:
- 1.4, SAX 2.0
- See Also:
- XMLReaderAdapter,- XMLReader,- Parser
 
- 
- 
Constructor SummaryConstructors Constructor Description ParserAdapter()Construct a new parser adapter.ParserAdapter(Parser parser)Construct a new parser adapter.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Adapter implementation method; do not call.voidendDocument()Adapter implementation method; do not call.voidendElement(String qName)Adapter implementation method; do not call.ContentHandlergetContentHandler()Return the current content handler.DTDHandlergetDTDHandler()Return the current DTD handler.EntityResolvergetEntityResolver()Return the current entity resolver.ErrorHandlergetErrorHandler()Return the current error handler.booleangetFeature(String name)Check a parser feature flag.ObjectgetProperty(String name)Get a parser property.voidignorableWhitespace(char[] ch, int start, int length)Adapter implementation method; do not call.voidparse(String systemId)Parse an XML document.voidparse(InputSource input)Parse an XML document.voidprocessingInstruction(String target, String data)Adapter implementation method; do not call.voidsetContentHandler(ContentHandler handler)Set the content handler.voidsetDocumentLocator(Locator locator)Adapter implementation method; do not call.voidsetDTDHandler(DTDHandler handler)Set the DTD handler.voidsetEntityResolver(EntityResolver resolver)Set the entity resolver.voidsetErrorHandler(ErrorHandler handler)Set the error handler.voidsetFeature(String name, boolean value)Set a feature flag for the parser.voidsetProperty(String name, Object value)Set a parser property.voidstartDocument()Adapter implementation method; do not call.voidstartElement(String qName, AttributeList qAtts)Adapter implementation method; do not call.
 
- 
- 
- 
Constructor Detail- 
ParserAdapterpublic ParserAdapter() throws SAXExceptionConstruct a new parser adapter.Use the "org.xml.sax.parser" property to locate the embedded SAX1 driver. - Throws:
- SAXException- If the embedded driver cannot be instantiated or if the org.xml.sax.parser property is not specified.
 
 - 
ParserAdapterpublic 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. - Parameters:
- parser- The SAX1 parser to embed.
- Throws:
- NullPointerException- If the parser parameter is null.
 
 
- 
 - 
Method Detail- 
setFeaturepublic 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. - Specified by:
- setFeaturein interface- XMLReader
- Parameters:
- name- The feature name, as a complete URI.
- value- The requested feature value.
- Throws:
- SAXNotRecognizedException- If the feature can't be assigned or retrieved.
- SAXNotSupportedException- If the feature can't be assigned that value.
- See Also:
- XMLReader.setFeature(java.lang.String, boolean)
 
 - 
getFeaturepublic boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException Check a parser feature flag.The only features recognized are namespaces and namespace-prefixes. - Specified by:
- getFeaturein interface- XMLReader
- Parameters:
- name- The feature name, as a complete URI.
- Returns:
- The current feature value.
- Throws:
- SAXNotRecognizedException- If the feature value can't be assigned or retrieved.
- SAXNotSupportedException- If the feature is not currently readable.
- See Also:
- XMLReader.setFeature(java.lang.String, boolean)
 
 - 
setPropertypublic void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException Set a parser property.No properties are currently recognized. - Specified by:
- setPropertyin interface- XMLReader
- Parameters:
- name- The property name.
- value- The property value.
- Throws:
- SAXNotRecognizedException- If the property value can't be assigned or retrieved.
- SAXNotSupportedException- If the property can't be assigned that value.
- See Also:
- XMLReader.setProperty(java.lang.String, java.lang.Object)
 
 - 
getPropertypublic Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException Get a parser property.No properties are currently recognized. - Specified by:
- getPropertyin interface- XMLReader
- Parameters:
- name- The property name.
- Returns:
- The property value.
- Throws:
- SAXNotRecognizedException- If the property value can't be assigned or retrieved.
- SAXNotSupportedException- If the property value is not currently readable.
- See Also:
- XMLReader.getProperty(java.lang.String)
 
 - 
setEntityResolverpublic void setEntityResolver(EntityResolver resolver) Set the entity resolver.- Specified by:
- setEntityResolverin interface- XMLReader
- Parameters:
- resolver- The new entity resolver.
- See Also:
- XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
 
 - 
getEntityResolverpublic EntityResolver getEntityResolver() Return the current entity resolver.- Specified by:
- getEntityResolverin interface- XMLReader
- Returns:
- The current entity resolver, or null if none was supplied.
- See Also:
- XMLReader.getEntityResolver()
 
 - 
setDTDHandlerpublic void setDTDHandler(DTDHandler handler) Set the DTD handler.- Specified by:
- setDTDHandlerin interface- XMLReader
- Parameters:
- handler- the new DTD handler
- See Also:
- XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
 
 - 
getDTDHandlerpublic DTDHandler getDTDHandler() Return the current DTD handler.- Specified by:
- getDTDHandlerin interface- XMLReader
- Returns:
- the current DTD handler, or null if none was supplied
- See Also:
- XMLReader.getEntityResolver()
 
 - 
setContentHandlerpublic void setContentHandler(ContentHandler handler) Set the content handler.- Specified by:
- setContentHandlerin interface- XMLReader
- Parameters:
- handler- the new content handler
- See Also:
- XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
 
 - 
getContentHandlerpublic ContentHandler getContentHandler() Return the current content handler.- Specified by:
- getContentHandlerin interface- XMLReader
- Returns:
- The current content handler, or null if none was supplied.
- See Also:
- XMLReader.getEntityResolver()
 
 - 
setErrorHandlerpublic void setErrorHandler(ErrorHandler handler) Set the error handler.- Specified by:
- setErrorHandlerin interface- XMLReader
- Parameters:
- handler- The new error handler.
- See Also:
- XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
 
 - 
getErrorHandlerpublic ErrorHandler getErrorHandler() Return the current error handler.- Specified by:
- getErrorHandlerin interface- XMLReader
- Returns:
- The current error handler, or null if none was supplied.
- See Also:
- XMLReader.getEntityResolver()
 
 - 
parsepublic void parse(String systemId) throws IOException, SAXException Parse an XML document.- Specified by:
- parsein interface- XMLReader
- Parameters:
- systemId- The absolute URL of the document.
- Throws:
- IOException- If there is a problem reading the raw content of the document.
- SAXException- If there is a problem processing the document.
- See Also:
- parse(org.xml.sax.InputSource),- Parser.parse(java.lang.String)
 
 - 
parsepublic void parse(InputSource input) throws IOException, SAXException Parse an XML document.- Specified by:
- parsein interface- XMLReader
- Parameters:
- input- An input source for the document.
- Throws:
- IOException- If there is a problem reading the raw content of the document.
- SAXException- If there is a problem processing the document.
- See Also:
- parse(java.lang.String),- Parser.parse(org.xml.sax.InputSource)
 
 - 
setDocumentLocatorpublic void setDocumentLocator(Locator locator) Adapter implementation method; do not call. Adapt a SAX1 document locator event.- Specified by:
- setDocumentLocatorin interface- DocumentHandler
- Parameters:
- locator- A document locator.
- See Also:
- ContentHandler.setDocumentLocator(org.xml.sax.Locator)
 
 - 
startDocumentpublic void startDocument() throws SAXExceptionAdapter implementation method; do not call. Adapt a SAX1 start document event.- Specified by:
- startDocumentin interface- DocumentHandler
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.startDocument()
 
 - 
endDocumentpublic void endDocument() throws SAXExceptionAdapter implementation method; do not call. Adapt a SAX1 end document event.- Specified by:
- endDocumentin interface- DocumentHandler
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.endDocument()
 
 - 
startElementpublic void startElement(String qName, AttributeList qAtts) throws SAXException Adapter implementation method; do not call. Adapt a SAX1 startElement event.If necessary, perform Namespace processing. - Specified by:
- startElementin interface- DocumentHandler
- Parameters:
- qName- The qualified (prefixed) name.
- qAtts- The XML attribute list (with qnames).
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.endElement(java.lang.String),- AttributeList
 
 - 
endElementpublic void endElement(String qName) throws SAXException Adapter implementation method; do not call. Adapt a SAX1 end element event.- Specified by:
- endElementin interface- DocumentHandler
- Parameters:
- qName- The qualified (prefixed) name.
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.endElement(java.lang.String)
 
 - 
characterspublic void characters(char[] ch, int start, int length) throws SAXExceptionAdapter implementation method; do not call. Adapt a SAX1 characters event.- Specified by:
- charactersin interface- DocumentHandler
- Parameters:
- ch- An array of characters.
- start- The starting position in the array.
- length- The number of characters to use.
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.characters(char[], int, int)
 
 - 
ignorableWhitespacepublic void ignorableWhitespace(char[] ch, int start, int length) throws SAXExceptionAdapter implementation method; do not call. Adapt a SAX1 ignorable whitespace event.- Specified by:
- ignorableWhitespacein interface- DocumentHandler
- Parameters:
- ch- An array of characters.
- start- The starting position in the array.
- length- The number of characters to use.
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.ignorableWhitespace(char[], int, int)
 
 - 
processingInstructionpublic void processingInstruction(String target, String data) throws SAXException Adapter implementation method; do not call. Adapt a SAX1 processing instruction event.- Specified by:
- processingInstructionin interface- DocumentHandler
- Parameters:
- target- The processing instruction target.
- data- The remainder of the processing instruction
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- DocumentHandler.processingInstruction(java.lang.String, java.lang.String)
 
 
- 
 
-