Class ParserAdapter
- All Implemented Interfaces:
- DocumentHandler, XMLReader
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.
- Since:
- 1.4, SAX 2.0
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct a new parser adapter.ParserAdapter(Parser parser) Construct a new parser adapter.
- 
Method SummaryModifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) Adapter implementation method; do not call.voidAdapter implementation method; do not call.voidendElement(String qName) Adapter implementation method; do not call.Return the current content handler.Return the current DTD handler.Return the current entity resolver.Return the current error handler.booleangetFeature(String name) Check a parser feature flag.getProperty(String name) Get a parser property.voidignorableWhitespace(char[] ch, int start, int length) Adapter implementation method; do not call.voidParse 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.voidAdapter implementation method; do not call.voidstartElement(String qName, AttributeList qAtts) Adapter implementation method; do not call.
- 
Constructor Details- 
ParserAdapterConstruct 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.
 
- 
ParserAdapterConstruct 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 Details- 
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:
 
- 
getFeatureCheck 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:
 
- 
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:
 
- 
getPropertyGet 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:
 
- 
setEntityResolverSet the entity resolver.- Specified by:
- setEntityResolverin interface- XMLReader
- Parameters:
- resolver- The new entity resolver.
- See Also:
 
- 
getEntityResolverReturn the current entity resolver.- Specified by:
- getEntityResolverin interface- XMLReader
- Returns:
- The current entity resolver, or null if none was supplied.
- See Also:
 
- 
setDTDHandlerSet the DTD handler.- Specified by:
- setDTDHandlerin interface- XMLReader
- Parameters:
- handler- the new DTD handler
- See Also:
 
- 
getDTDHandlerReturn the current DTD handler.- Specified by:
- getDTDHandlerin interface- XMLReader
- Returns:
- the current DTD handler, or null if none was supplied
- See Also:
 
- 
setContentHandlerSet the content handler.- Specified by:
- setContentHandlerin interface- XMLReader
- Parameters:
- handler- the new content handler
- See Also:
 
- 
getContentHandlerReturn the current content handler.- Specified by:
- getContentHandlerin interface- XMLReader
- Returns:
- The current content handler, or null if none was supplied.
- See Also:
 
- 
setErrorHandlerSet the error handler.- Specified by:
- setErrorHandlerin interface- XMLReader
- Parameters:
- handler- The new error handler.
- See Also:
 
- 
getErrorHandlerReturn the current error handler.- Specified by:
- getErrorHandlerin interface- XMLReader
- Returns:
- The current error handler, or null if none was supplied.
- See Also:
 
- 
parseParse 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:
 
- 
parseParse 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:
 
- 
setDocumentLocatorAdapter implementation method; do not call. Adapt a SAX1 document locator event.- Specified by:
- setDocumentLocatorin interface- DocumentHandler
- Parameters:
- locator- A document locator.
- See Also:
 
- 
startDocumentAdapter 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:
 
- 
endDocumentAdapter 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:
 
- 
startElementAdapter 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:
 
- 
endElementAdapter 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:
 
- 
charactersAdapter 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:
 
- 
ignorableWhitespaceAdapter 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:
 
- 
processingInstructionAdapter 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:
 
 
-