org.apache.oodt.commons.util
Class SAXParser

java.lang.Object
  extended by org.apache.oodt.commons.util.SAXParser

public class SAXParser
extends Object

An XML Simple API for XML (SAX) parser. Objects of this class are SAX parsers.

Author:
Kelly

Method Summary
 ContentHandler getContentHandler()
          Return the current content handler.
 DTDHandler getDTDHandler()
          Return the current DTD handler.
 EntityResolver getEntityResolver()
          Return the current entity resolver.
 ErrorHandler getErrorHandler()
          Return the current error handler.
 boolean getFeature(String featureId)
          Query the current state of any feature in a SAX2 parser.
 String[] getFeaturesRecognized()
          Returns a list of features that this parser recognizes.
 Locator getLocator()
          return the locator being used by the parser
 String[] getPropertiesRecognized()
          Returns a list of properties that this parser recognizes.
 Object getProperty(String propertyId)
          Return the current value of a property in a SAX2 parser.
 boolean isFeatureRecognized(String featureId)
          Returns true if the specified feature is recognized.
 boolean isPropertyRecognized(String propertyId)
          Returns true if the specified property is recognized.
 void parse(InputSource source)
          Parses the specified input source.
 void parse(String systemID)
          Parses the input source specified by the given system identifier.
 void reset()
          Resets the parser.
 void setContentHandler(ContentHandler handler)
          Allow an application to register a content event handler.
 void setDTDHandler(DTDHandler handler)
          Allow an application to register a DTD event handler.
 void setEntityResolver(EntityResolver resolver)
          Sets the resolver used to resolve external entities.
 void setErrorHandler(ErrorHandler handler)
          Sets the error handler.
 void setFeature(String featureId, boolean state)
          Set the state of any feature in a SAX2 parser.
 void setLocale(Locale locale)
          Set the locale to use for messages.
 void setProperty(String propertyId, Object value)
          Set the value of any property in a SAX2 parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFeaturesRecognized

public String[] getFeaturesRecognized()
Returns a list of features that this parser recognizes. This method will never return null; if no features are recognized, this method will return a zero length array.

Returns:
Recognized features.

getPropertiesRecognized

public String[] getPropertiesRecognized()
Returns a list of properties that this parser recognizes. This method will never return null; if no properties are recognized, this method will return a zero length array.

Returns:
Recognized properties.

reset

public void reset()
Resets the parser.


setFeature

public void setFeature(String featureId,
                       boolean state)
                throws SAXNotRecognizedException,
                       SAXNotSupportedException
Set the state of any feature in a SAX2 parser. The parser might not recognize the feature, and if it does recognize it, it might not be able to fulfill the request.

Parameters:
featureId - The unique identifier (URI) of the feature.
state - The requested state of the feature (true or false).
Throws:
SAXNotRecognizedException - If the requested feature is not known.
SAXNotSupportedException - If the requested feature is known, but the requested state is not supported.

getFeature

public boolean getFeature(String featureId)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Query the current state of any feature in a SAX2 parser. The parser might not recognize the feature.

Parameters:
featureId - The unique identifier (URI) of the feature being set.
Returns:
The current state of the feature.
Throws:
SAXNotRecognizedException - If the requested feature is not known.
SAXNotSupportedException

setProperty

public void setProperty(String propertyId,
                        Object value)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Set the value of any property in a SAX2 parser. The parser might not recognize the property, and if it does recognize it, it might not support the requested value.

Parameters:
propertyId - The unique identifier (URI) of the property being set.
value - The value to which the property is being set.
Throws:
SAXNotRecognizedException - If the requested property is not known.
SAXNotSupportedException - If the requested property is known, but the requested value is not supported.

getProperty

public Object getProperty(String propertyId)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Return the current value of a property in a SAX2 parser. The parser might not recognize the property.

Parameters:
propertyId - The unique identifier (URI) of the property being set.
Returns:
The current value of the property.
Throws:
SAXNotRecognizedException - If the requested property is not known.
SAXNotSupportedException

isFeatureRecognized

public boolean isFeatureRecognized(String featureId)
Returns true if the specified feature is recognized.


isPropertyRecognized

public boolean isPropertyRecognized(String propertyId)
Returns true if the specified property is recognized.


getLocator

public final Locator getLocator()
return the locator being used by the parser

Returns:
the parser's active locator

setEntityResolver

public void setEntityResolver(EntityResolver resolver)
Sets the resolver used to resolve external entities. The EntityResolver interface supports resolution of public and system identifiers.

Parameters:
resolver - The new entity resolver. Passing a null value will uninstall the currently installed resolver.

getEntityResolver

public EntityResolver getEntityResolver()
Return the current entity resolver.

Returns:
The current entity resolver, or null if none has been registered.
See Also:
setEntityResolver(org.xml.sax.EntityResolver)

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Sets the error handler.

Parameters:
handler - The new error handler.

getErrorHandler

public ErrorHandler getErrorHandler()
Return the current error handler.

Returns:
The current error handler, or null if none has been registered.
See Also:
setErrorHandler(org.xml.sax.ErrorHandler)

parse

public void parse(InputSource source)
           throws SAXException,
                  IOException
Parses the specified input source.

Parameters:
source - The input source.
Throws:
SAXException - Throws exception on SAX error.
IOException - Throws exception on i/o error.

parse

public void parse(String systemID)
           throws SAXException,
                  IOException
Parses the input source specified by the given system identifier.

This method is equivalent to the following:

     parse(new InputSource(systemId));
 

Parameters:
systemID - The input source.
Throws:
SAXException - Throws exception on SAX error.
IOException - Throws exception on i/o error.

setLocale

public void setLocale(Locale locale)
               throws SAXException
Set the locale to use for messages.

Parameters:
locale - The locale object to use for localization of messages.
Throws:
SAXException - An exception thrown if the parser does not support the specified locale.

setDTDHandler

public void setDTDHandler(DTDHandler handler)
Allow an application to register a DTD event handler.

If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters:
handler - The DTD handler.
Throws:
NullPointerException - If the handler argument is null.
See Also:
getDTDHandler()

getDTDHandler

public DTDHandler getDTDHandler()
Return the current DTD handler.

Returns:
The current DTD handler, or null if none has been registered.
See Also:
setDTDHandler(org.xml.sax.DTDHandler)

setContentHandler

public void setContentHandler(ContentHandler handler)
Allow an application to register a content event handler.

If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored.

Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.

Parameters:
handler - The content handler.
Throws:
NullPointerException - If the handler argument is null.
See Also:
getContentHandler()

getContentHandler

public ContentHandler getContentHandler()
Return the current content handler.

Returns:
The current content handler, or null if none has been registered.
See Also:
setContentHandler(org.xml.sax.ContentHandler)


Copyright © 1999-2013
Apache OODT. All Rights Reserved.