Movatterモバイル変換


[0]ホーム

URL:


         


Class ParserAdapter

java.lang.Object  |  +--org.xml.sax.helpers.ParserAdapter
All Implemented Interfaces:
DocumentHandler,XMLReader

public classParserAdapter
extends java.lang.Object
implementsXMLReader,DocumentHandler

Adapt a SAX1 Parser as a SAX2 XMLReader.

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

This class wraps a SAX1Parser and makes it act as a SAX2XMLReader, with feature, property, and Namespace support. Note that it is not possible to reportskippedEntity events, since SAX1 does not make that information available.

This adapter does not test for duplicate Namespace-qualified attribute names.

Since:
SAX 2.0
See Also:
XMLReaderAdapter,XMLReader,Parser

ParserAdapter()
          Construct a new parser adapter.
ParserAdapter(Parser parser)
          Construct a new parser adapter.
 
characters(char[] ch, int start, int length)
          Adapt a SAX1 characters event.
endDocument()
          Adapt a SAX1 end document event.
endElement(java.lang.String qName)
          Adapt a SAX1 end element event.
getContentHandler()
          Return the current content handler.
getDTDHandler()
          Return the current DTD handler.
getEntityResolver()
          Return the current entity resolver.
getErrorHandler()
          Return the current error handler.
getFeature(java.lang.String name)
          Check a parser feature.
getProperty(java.lang.String name)
          Get a parser property.
ignorableWhitespace(char[] ch, int start, int length)
          Adapt a SAX1 ignorable whitespace event.
parse(InputSource input)
          Parse an XML document.
parse(java.lang.String systemId)
          Parse an XML document.
processingInstruction(java.lang.String target, java.lang.String data)
          Adapt a SAX1 processing instruction event.
setContentHandler(ContentHandler handler)
          Set the content handler.
setDocumentLocator(Locator locator)
          Adapt a SAX1 document locator event.
setDTDHandler(DTDHandler handler)
          Set the DTD handler.
setEntityResolver(EntityResolver resolver)
          Set the entity resolver.
setErrorHandler(ErrorHandler handler)
          Set the error handler.
setFeature(java.lang.String name, boolean state)
          Set a feature for the parser.
setProperty(java.lang.String name, java.lang.Object value)
          Set a parser property.
startDocument()
          Adapt a SAX1 start document event.
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
 

ParserAdapter

publicParserAdapter()              throwsSAXException
Construct 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.

ParserAdapter

publicParserAdapter(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:
java.lang.NullPointerException - If the parser parameter is null.

setFeature

public voidsetFeature(java.lang.String name,                       boolean state)                throwsSAXNotRecognizedException,SAXNotSupportedException
Set a feature for the parser.

The only features supported are namespaces and namespace-prefixes.

Specified by:
setFeature in interfaceXMLReader
Parameters:
name - The feature name, as a complete URI.
state - The requested feature state.
Throws:
SAXNotRecognizedException - If the feature name is not known.
SAXNotSupportedException - If the feature state is not supported.
See Also:
XMLReader.setFeature(java.lang.String, boolean)

getFeature

public booleangetFeature(java.lang.String name)                   throwsSAXNotRecognizedException,SAXNotSupportedException
Check a parser feature.

The only features supported are namespaces and namespace-prefixes.

Specified by:
getFeature in interfaceXMLReader
Parameters:
name - The feature name, as a complete URI.
Returns:
The current feature state.
Throws:
SAXNotRecognizedException - If the feature name is not known.
SAXNotSupportedException - If querying the feature state is not supported.
See Also:
XMLReader.setFeature(java.lang.String, boolean)

setProperty

public voidsetProperty(java.lang.String name,                        java.lang.Object value)                 throwsSAXNotRecognizedException,SAXNotSupportedException
Set a parser property.

No special properties are currently supported.

Specified by:
setProperty in interfaceXMLReader
Parameters:
name - The property name.
value - The property value.
Throws:
SAXNotRecognizedException - If the feature name is not known.
SAXNotSupportedException - If the feature state is not supported.
See Also:
XMLReader.setProperty(java.lang.String, java.lang.Object)

getProperty

public java.lang.ObjectgetProperty(java.lang.String name)                             throwsSAXNotRecognizedException,SAXNotSupportedException
Get a parser property.

No special properties are currently supported.

Specified by:
getProperty in interfaceXMLReader
Parameters:
name - The property name.
Returns:
The property value.
Throws:
SAXNotRecognizedException - If the feature name is not known.
SAXNotSupportedException - If the feature state is not supported.
See Also:
XMLReader.getProperty(java.lang.String)

setEntityResolver

public voidsetEntityResolver(EntityResolver resolver)
Set the entity resolver.
Specified by:
setEntityResolver in interfaceXMLReader
Parameters:
resolver - The new entity resolver.
Throws:
java.lang.NullPointerException - If the entity resolver parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getEntityResolver

publicEntityResolvergetEntityResolver()
Return the current entity resolver.
Specified by:
getEntityResolver in interfaceXMLReader
Returns:
The current entity resolver, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

setDTDHandler

public voidsetDTDHandler(DTDHandler handler)
Set the DTD handler.
Specified by:
setDTDHandler in interfaceXMLReader
Parameters:
resolver - The new DTD handler.
Throws:
java.lang.NullPointerException - If the DTD handler parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getDTDHandler

publicDTDHandlergetDTDHandler()
Return the current DTD handler.
Specified by:
getDTDHandler in interfaceXMLReader
Returns:
The current DTD handler, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

setContentHandler

public voidsetContentHandler(ContentHandler handler)
Set the content handler.
Specified by:
setContentHandler in interfaceXMLReader
Parameters:
resolver - The new content handler.
Throws:
java.lang.NullPointerException - If the content handler parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getContentHandler

publicContentHandlergetContentHandler()
Return the current content handler.
Specified by:
getContentHandler in interfaceXMLReader
Returns:
The current content handler, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

setErrorHandler

public voidsetErrorHandler(ErrorHandler handler)
Set the error handler.
Specified by:
setErrorHandler in interfaceXMLReader
Parameters:
resolver - The new error handler.
Throws:
java.lang.NullPointerException - If the error handler parameter is null.
See Also:
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)

getErrorHandler

publicErrorHandlergetErrorHandler()
Return the current error handler.
Specified by:
getErrorHandler in interfaceXMLReader
Returns:
The current error handler, or null if none was supplied.
See Also:
XMLReader.getEntityResolver()

parse

public voidparse(java.lang.String systemId)           throws java.io.IOException,SAXException
Parse an XML document.
Specified by:
parse in interfaceXMLReader
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 an XML document.
Specified by:
parse in interfaceXMLReader
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)
Adapt a SAX1 document locator event.
Specified by:
setDocumentLocator in interfaceDocumentHandler
Parameters:
locator - A document locator.
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)

startDocument

public voidstartDocument()                   throwsSAXException
Adapt a SAX1 start document event.
Specified by:
startDocument in interfaceDocumentHandler
Throws:
SAXException - The client may raise a processing exception.
See Also:
DocumentHandler.startDocument()

endDocument

public voidendDocument()                 throwsSAXException
Adapt a SAX1 end document event.
Specified by:
endDocument in interfaceDocumentHandler
Throws:
SAXException - The client may raise a processing exception.
See Also:
DocumentHandler.endDocument()

startElement

public voidstartElement(java.lang.String qName,AttributeList qAtts)                  throwsSAXException
Adapt a SAX1 startElement event.

If necessary, perform Namespace processing.

Specified by:
startElement in interfaceDocumentHandler
Parameters:
qName - The qualified (prefixed) name.
qAtts - The XML 1.0 attribute list (with qnames).

endElement

public voidendElement(java.lang.String qName)                throwsSAXException
Adapt a SAX1 end element event.
Specified by:
endElement in interfaceDocumentHandler
Parameters:
qName - The qualified (prefixed) name.
Throws:
SAXException - The client may raise a processing exception.
See Also:
DocumentHandler.endElement(java.lang.String)

characters

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

ignorableWhitespace

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

processingInstruction

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

         


[8]ページ先頭

©2009-2025 Movatter.jp