- java.lang.Object
- 
- org.xml.sax.helpers.XMLReaderAdapter
 
- 
- All Implemented Interfaces:
- ContentHandler,- Parser
 
 public class XMLReaderAdapter extends Object implements Parser, ContentHandler Adapt a SAX2 XMLReader as a SAX1 Parser.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 SAX2 XMLReaderand makes it act as a SAX1Parser. The XMLReader must support a true value for the http://xml.org/sax/features/namespace-prefixes property or parsing will fail with aSAXException; if the XMLReader supports a false value for the http://xml.org/sax/features/namespaces property, that will also be used to improve efficiency.
- 
- 
Constructor SummaryConstructors Constructor Description XMLReaderAdapter()Create a new adapter.XMLReaderAdapter(XMLReader xmlReader)Create a new adapter.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Adapt a SAX2 characters event.voidendDocument()End document event.voidendElement(String uri, String localName, String qName)Adapt a SAX2 end element event.voidendPrefixMapping(String prefix)Adapt a SAX2 end prefix mapping event.voidignorableWhitespace(char[] ch, int start, int length)Adapt a SAX2 ignorable whitespace event.voidparse(String systemId)Parse the document.voidparse(InputSource input)Parse the document.voidprocessingInstruction(String target, String data)Adapt a SAX2 processing instruction event.voidsetDocumentHandler(DocumentHandler handler)Register the SAX1 document event handler.voidsetDocumentLocator(Locator locator)Set a document locator.voidsetDTDHandler(DTDHandler handler)Register the DTD event handler.voidsetEntityResolver(EntityResolver resolver)Register the entity resolver.voidsetErrorHandler(ErrorHandler handler)Register the error event handler.voidsetLocale(Locale locale)Set the locale for error reporting.voidskippedEntity(String name)Adapt a SAX2 skipped entity event.voidstartDocument()Start document event.voidstartElement(String uri, String localName, String qName, Attributes atts)Adapt a SAX2 start element event.voidstartPrefixMapping(String prefix, String uri)Adapt a SAX2 start prefix mapping event.
 
- 
- 
- 
Constructor Detail- 
XMLReaderAdapterpublic XMLReaderAdapter() throws SAXExceptionCreate a new adapter.Use the "org.xml.sax.driver" property to locate the SAX2 driver to embed. - Throws:
- SAXException- If the embedded driver cannot be instantiated or if the org.xml.sax.driver property is not specified.
 
 - 
XMLReaderAdapterpublic XMLReaderAdapter(XMLReader xmlReader) Create a new adapter.Create a new adapter, wrapped around a SAX2 XMLReader. The adapter will make the XMLReader act like a SAX1 Parser. - Parameters:
- xmlReader- The SAX2 XMLReader to wrap.
- Throws:
- NullPointerException- If the argument is null.
 
 
- 
 - 
Method Detail- 
setLocalepublic void setLocale(Locale locale) throws SAXException Set the locale for error reporting.This is not supported in SAX2, and will always throw an exception. - Specified by:
- setLocalein interface- Parser
- Parameters:
- locale- the locale for error reporting.
- Throws:
- SAXException- Thrown unless overridden.
- See Also:
- Parser.setLocale(java.util.Locale)
 
 - 
setEntityResolverpublic void setEntityResolver(EntityResolver resolver) Register the entity resolver.- Specified by:
- setEntityResolverin interface- Parser
- Parameters:
- resolver- The new resolver.
- See Also:
- Parser.setEntityResolver(org.xml.sax.EntityResolver)
 
 - 
setDTDHandlerpublic void setDTDHandler(DTDHandler handler) Register the DTD event handler.- Specified by:
- setDTDHandlerin interface- Parser
- Parameters:
- handler- The new DTD event handler.
- See Also:
- Parser.setDTDHandler(org.xml.sax.DTDHandler)
 
 - 
setDocumentHandlerpublic void setDocumentHandler(DocumentHandler handler) Register the SAX1 document event handler.Note that the SAX1 document handler has no Namespace support. - Specified by:
- setDocumentHandlerin interface- Parser
- Parameters:
- handler- The new SAX1 document event handler.
- See Also:
- Parser.setDocumentHandler(org.xml.sax.DocumentHandler)
 
 - 
setErrorHandlerpublic void setErrorHandler(ErrorHandler handler) Register the error event handler.- Specified by:
- setErrorHandlerin interface- Parser
- Parameters:
- handler- The new error event handler.
- See Also:
- Parser.setErrorHandler(org.xml.sax.ErrorHandler)
 
 - 
parsepublic void parse(String systemId) throws IOException, SAXException Parse the document.This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property. - Specified by:
- parsein interface- Parser
- 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 the document.This method will throw an exception if the embedded XMLReader does not support the http://xml.org/sax/features/namespace-prefixes property. - Specified by:
- parsein interface- Parser
- 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) Set a document locator.- Specified by:
- setDocumentLocatorin interface- ContentHandler
- Parameters:
- locator- The document locator.
- See Also:
- ContentHandler.setDocumentLocator(org.xml.sax.Locator)
 
 - 
startDocumentpublic void startDocument() throws SAXExceptionStart document event.- Specified by:
- startDocumentin interface- ContentHandler
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- ContentHandler.startDocument()
 
 - 
endDocumentpublic void endDocument() throws SAXExceptionEnd document event.- Specified by:
- endDocumentin interface- ContentHandler
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- ContentHandler.endDocument()
 
 - 
startPrefixMappingpublic void startPrefixMapping(String prefix, String uri) Adapt a SAX2 start prefix mapping event.- Specified by:
- startPrefixMappingin interface- ContentHandler
- Parameters:
- prefix- The prefix being mapped.
- uri- The Namespace URI being mapped to.
- See Also:
- ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
 
 - 
endPrefixMappingpublic void endPrefixMapping(String prefix) Adapt a SAX2 end prefix mapping event.- Specified by:
- endPrefixMappingin interface- ContentHandler
- Parameters:
- prefix- The prefix being mapped.
- See Also:
- ContentHandler.endPrefixMapping(java.lang.String)
 
 - 
startElementpublic void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException Adapt a SAX2 start element event.- Specified by:
- startElementin interface- ContentHandler
- Parameters:
- uri- The Namespace URI.
- localName- The Namespace local name.
- qName- The qualified (prefixed) name.
- atts- The SAX2 attributes.
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- ContentHandler.endDocument()
 
 - 
endElementpublic void endElement(String uri, String localName, String qName) throws SAXException Adapt a SAX2 end element event.- Specified by:
- endElementin interface- ContentHandler
- Parameters:
- uri- The Namespace URI.
- localName- The Namespace local name.
- qName- The qualified (prefixed) name.
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
 
 - 
characterspublic void characters(char[] ch, int start, int length) throws SAXExceptionAdapt a SAX2 characters event.- Specified by:
- charactersin interface- ContentHandler
- 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:
- ContentHandler.characters(char[], int, int)
 
 - 
ignorableWhitespacepublic void ignorableWhitespace(char[] ch, int start, int length) throws SAXExceptionAdapt a SAX2 ignorable whitespace event.- Specified by:
- ignorableWhitespacein interface- ContentHandler
- 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:
- ContentHandler.ignorableWhitespace(char[], int, int)
 
 - 
processingInstructionpublic void processingInstruction(String target, String data) throws SAXException Adapt a SAX2 processing instruction event.- Specified by:
- processingInstructionin interface- ContentHandler
- Parameters:
- target- The processing instruction target.
- data- The remainder of the processing instruction
- Throws:
- SAXException- The client may raise a processing exception.
- See Also:
- ContentHandler.processingInstruction(java.lang.String, java.lang.String)
 
 - 
skippedEntitypublic void skippedEntity(String name) throws SAXException Adapt a SAX2 skipped entity event.- Specified by:
- skippedEntityin interface- ContentHandler
- Parameters:
- name- The name of the skipped entity.
- Throws:
- SAXException- Throwable by subclasses.
- See Also:
- ContentHandler.skippedEntity(java.lang.String)
 
 
- 
 
-