org.xml.sax.helpers
Class ConfigurableParserAdapter

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

public class ConfigurableParserAdapter
extends java.lang.Object
implements Parser, Configurable

Adapt a SAX1 parser to implement the Configurable interface. This class implements the SAX1 Parser interface and the SAX2 Configurable interface by embedding another Parser instance. If the embedded parser already implements the Configurable interface, it will be used directly; otherwise, the parser will not know about any features or properties, and will throw a SAXNotRecognizedException for all of them.

See Also:
Parser, Configurable

Constructor Summary
ConfigurableParserAdapter(Parser parser)
          Construct a SAX2 parser by embedding another SAX parser.
 
Method Summary
 boolean getFeature(java.lang.String featureId)
          Get the state of a feature.
 java.lang.Object getProperty(java.lang.String propertyId)
          Get the state of a property.
 void parse(InputSource source)
          Parse an XML document from an InputSource.
 void parse(java.lang.String systemId)
          Parse an XML document from a fully-qualified system ID.
 void setDocumentHandler(DocumentHandler handler)
          Set the parser's document event handler.
 void setDTDHandler(DTDHandler handler)
          Set the parser's DTD event handler.
 void setEntityResolver(EntityResolver resolver)
          Set the parser's entity resolver.
 void setErrorHandler(ErrorHandler handler)
          Set the parser's error event handler.
 void setFeature(java.lang.String featureId, boolean state)
          Set the state of a feature.
 void setLocale(java.util.Locale locale)
          Set the locale for error reporting.
 void setProperty(java.lang.String propertyId, java.lang.Object value)
          Set the state of a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurableParserAdapter

public ConfigurableParserAdapter(Parser parser)
Construct a SAX2 parser by embedding another SAX parser. If the embedded parser does not know about the Configurable interface, this class will implement the interface for it.

Parameters:
parser - The embedded SAX parser.
Method Detail

setLocale

public void setLocale(java.util.Locale locale)
               throws SAXException
Set the locale for error reporting. Pass on to the embedded parser.

Specified by:
setLocale in interface Parser
Parameters:
locale - A Java Locale object.
Throws:
SAXException - If the locale is not supported.
See Also:
Parser.setLocale(java.util.Locale)

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Set the parser's entity resolver. Pass on to the embedded parser.

Specified by:
setEntityResolver in interface Parser
Parameters:
resolver - The application-provided entity resolver.
See Also:
Parser.setEntityResolver(org.xml.sax.EntityResolver)

setDTDHandler

public void setDTDHandler(DTDHandler handler)
Set the parser's DTD event handler. Pass on to the embedded parser.

Specified by:
setDTDHandler in interface Parser
Parameters:
handler - The application-provided DTD event handler.
See Also:
Parser.setDTDHandler(org.xml.sax.DTDHandler)

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)
Set the parser's document event handler. Pass on to the embedded parser.

Specified by:
setDocumentHandler in interface Parser
Parameters:
handler - The application-provided document event handler.
See Also:
Parser.setDocumentHandler(org.xml.sax.DocumentHandler)

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Set the parser's error event handler. Pass on to the embedded parser.

Specified by:
setErrorHandler in interface Parser
Parameters:
handler - The application-provided error event handler.
See Also:
Parser.setErrorHandler(org.xml.sax.ErrorHandler)

parse

public void parse(InputSource source)
           throws SAXException,
                  java.io.IOException
Parse an XML document from an InputSource. Pass on to the embedded parser.

Specified by:
parse in interface Parser
Parameters:
source - The InputSource for the XML document.
Throws:
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
Parser.parse(org.xml.sax.InputSource)

parse

public void parse(java.lang.String systemId)
           throws SAXException,
                  java.io.IOException
Parse an XML document from a fully-qualified system ID. Pass on to the embedded parser.

Specified by:
parse in interface Parser
Parameters:
systemId - The system identifier (URI) for the document.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
java.io.IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
See Also:
Parser.parse(java.lang.String)

setFeature

public void setFeature(java.lang.String featureId,
                       boolean state)
                throws SAXException
Set the state of a feature. Always fails unless the embedded parser supports Configurable.

Specified by:
setFeature in interface Configurable
Parameters:
featureId - The unique identifier (URI) of the feature.
state - The requested state of the feature (true or false).
Throws:
SAXException - If there is any other problem fulfilling the request.
See Also:
Configurable.setFeature(java.lang.String, boolean)

getFeature

public boolean getFeature(java.lang.String featureId)
                   throws SAXException
Get the state of a feature. Always fails unless the embedded parser supports Configurable.

Specified by:
getFeature in interface Configurable
Parameters:
featureId - The unique identifier (URI) of the feature being set.
Returns:
The current state of the feature.
Throws:
SAXException - If there is any other problem fulfilling the request.
See Also:
Configurable.getFeature(java.lang.String)

setProperty

public void setProperty(java.lang.String propertyId,
                        java.lang.Object value)
                 throws SAXException
Set the state of a property. Always fails unless the embedded parser supports Configurable.

Specified by:
setProperty in interface Configurable
Parameters:
propertyId - The unique identifier (URI) of the property being set.
Throws:
SAXException - If there is any other problem fulfilling the request.
See Also:
Configurable.setProperty(java.lang.String, java.lang.Object)

getProperty

public java.lang.Object getProperty(java.lang.String propertyId)
                             throws SAXException
Get the state of a property. Always fails unless the embedded parser supports Configurable.

Specified by:
getProperty in interface Configurable
Parameters:
propertyId - The unique identifier (URI) of the property being set.
Returns:
The current value of the property.
Throws:
SAXException - If there is any other problem fulfilling the request.
See Also:
Configurable.getProperty(java.lang.String)