Movatterモバイル変換


[0]ホーム

URL:


         


Class XMLReaderAdapter

java.lang.Object  |  +--org.xml.sax.helpers.XMLReaderAdapter
All Implemented Interfaces:
ContentHandler,Parser

public classXMLReaderAdapter
extends java.lang.Object
implementsParser,ContentHandler

Adapt a SAX2 XMLReader as a SAX1 Parser.

This module, both source code and documentation, is in the Public Domain, and comes withNO WARRANTY.

This class wraps a SAX2XMLReader and 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.

Since:
SAX 2.0
See Also:
Parser,XMLReader

XMLReaderAdapter()
          Create a new adapter.
XMLReaderAdapter(XMLReader xmlReader)
          Create a new adapter.
 
characters(char[] ch, int start, int length)
          Adapt a SAX2 characters event.
endDocument()
          End document event.
endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Adapt a SAX2 end element event.
endPrefixMapping(java.lang.String prefix)
          Adapt a SAX2 end prefix mapping event.
ignorableWhitespace(char[] ch, int start, int length)
          Adapt a SAX2 ignorable whitespace event.
parse(InputSource input)
          Parse the document.
parse(java.lang.String systemId)
          Parse the document.
processingInstruction(java.lang.String target, java.lang.String data)
          Adapt a SAX2 processing instruction event.
setDocumentHandler(DocumentHandler handler)
          Register the SAX1 document event handler.
setDocumentLocator(Locator locator)
          Set a document locator.
setDTDHandler(DTDHandler handler)
          Register the DTD event handler.
setEntityResolver(EntityResolver resolver)
          Register the entity resolver.
setErrorHandler(ErrorHandler handler)
          Register the error event handler.
setLocale(java.util.Locale locale)
          Set the locale for error reporting.
skippedEntity(java.lang.String name)
          Adapt a SAX2 skipped entity event.
startDocument()
          Start document event.
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName,Attributes atts)
          Adapt a SAX2 start element event.
startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Adapt a SAX2 start prefix mapping event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

XMLReaderAdapter

publicXMLReaderAdapter()                 throwsSAXException
Create 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.

XMLReaderAdapter

publicXMLReaderAdapter(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:
java.lang.NullPointerException - If the argument is null.

setLocale

public voidsetLocale(java.util.Locale locale)               throwsSAXException
Set the locale for error reporting.

This is not supported in SAX2, and will always throw an exception.

Specified by:
setLocale in interfaceParser
Parameters:
The - locale for error reporting.
See Also:
Parser.setLocale(java.util.Locale)

setEntityResolver

public voidsetEntityResolver(EntityResolver resolver)
Register the entity resolver.
Specified by:
setEntityResolver in interfaceParser
Parameters:
resolver - The new resolver.
See Also:
Parser.setEntityResolver(org.xml.sax.EntityResolver)

setDTDHandler

public voidsetDTDHandler(DTDHandler handler)
Register the DTD event handler.
Specified by:
setDTDHandler in interfaceParser
Parameters:
handler - The new DTD event handler.
See Also:
Parser.setDTDHandler(org.xml.sax.DTDHandler)

setDocumentHandler

public voidsetDocumentHandler(DocumentHandler handler)
Register the SAX1 document event handler.

Note that the SAX1 document handler has no Namespace support.

Specified by:
setDocumentHandler in interfaceParser
Parameters:
handler - The new SAX1 document event handler.
See Also:
Parser.setDocumentHandler(org.xml.sax.DocumentHandler)

setErrorHandler

public voidsetErrorHandler(ErrorHandler handler)
Register the error event handler.
Specified by:
setErrorHandler in interfaceParser
Parameters:
handler - The new error event handler.
See Also:
Parser.setErrorHandler(org.xml.sax.ErrorHandler)

parse

public voidparse(java.lang.String systemId)           throws java.io.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:
parse in interfaceParser
Parameters:
systemId - The absolute URL of the document.
Throws:
java.io.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)

parse

public voidparse(InputSource input)           throws java.io.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:
parse in interfaceParser
Parameters:
input - An input source for the document.
Throws:
java.io.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)

setDocumentLocator

public voidsetDocumentLocator(Locator locator)
Set a document locator.
Specified by:
setDocumentLocator in interfaceContentHandler
Parameters:
locator - The document locator.
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)

startDocument

public voidstartDocument()                   throwsSAXException
Start document event.
Specified by:
startDocument in interfaceContentHandler
Throws:
SAXException - The client may raise a processing exception.
See Also:
ContentHandler.startDocument()

endDocument

public voidendDocument()                 throwsSAXException
End document event.
Specified by:
endDocument in interfaceContentHandler
Throws:
SAXException - The client may raise a processing exception.
See Also:
ContentHandler.endDocument()

startPrefixMapping

public voidstartPrefixMapping(java.lang.String prefix,                               java.lang.String uri)
Adapt a SAX2 start prefix mapping event.
Specified by:
startPrefixMapping in interfaceContentHandler
Parameters:
prefix - The prefix being mapped.
uri - The Namespace URI being mapped to.
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public voidendPrefixMapping(java.lang.String prefix)
Adapt a SAX2 end prefix mapping event.
Specified by:
endPrefixMapping in interfaceContentHandler
Parameters:
prefix - The prefix being mapped.
See Also:
ContentHandler.endPrefixMapping(java.lang.String)

startElement

public voidstartElement(java.lang.String uri,                         java.lang.String localName,                         java.lang.String qName,Attributes atts)                  throwsSAXException
Adapt a SAX2 start element event.
Specified by:
startElement in interfaceContentHandler
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()

endElement

public voidendElement(java.lang.String uri,                       java.lang.String localName,                       java.lang.String qName)                throwsSAXException
Adapt a SAX2 end element event.
Specified by:
endElement in interfaceContentHandler
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)

characters

public voidcharacters(char[] ch,                       int start,                       int length)                throwsSAXException
Adapt a SAX2 characters event.
Specified by:
characters in interfaceContentHandler
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)

ignorableWhitespace

public voidignorableWhitespace(char[] ch,                                int start,                                int length)                         throwsSAXException
Adapt a SAX2 ignorable whitespace event.
Specified by:
ignorableWhitespace in interfaceContentHandler
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)

processingInstruction

public voidprocessingInstruction(java.lang.String target,                                  java.lang.String data)                           throwsSAXException
Adapt a SAX2 processing instruction event.
Specified by:
processingInstruction in interfaceContentHandler
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)

skippedEntity

public voidskippedEntity(java.lang.String name)                   throwsSAXException
Adapt a SAX2 skipped entity event.
Specified by:
skippedEntity in interfaceContentHandler
Parameters:
name - The name of the skipped entity.
See Also:
ContentHandler.skippedEntity(java.lang.String)

         


[8]ページ先頭

©2009-2025 Movatter.jp