public abstract class

SAXParser

extends Object
java.lang.Object
   ↳ javax.xml.parsers.SAXParser

Class Overview

Provides a wrapper around a SAX XMLReader. This abstract class only defines the interface, whereas the SAXParserFactory class is used to obtain instances of concrete subclasses.

Summary

Protected Constructors
SAXParser()
Do-nothing constructor.
Public Methods
abstract Parser getParser()
Queries the underlying SAX Parser object.
abstract Object getProperty(String name)
Queries a property of the underlying SAX XMLReader.
abstract XMLReader getXMLReader()
Queries the underlying SAX XMLReader object.
abstract boolean isNamespaceAware()
Reflects whether this SAXParser is namespace-aware.
abstract boolean isValidating()
Reflects whether this SAXParser is validating.
boolean isXIncludeAware()
Reflects whether this SAXParser is XInclude-aware.
void parse(InputStream stream, DefaultHandler handler)
Parses the given XML InputStream using the given SAX event handler.
void parse(InputStream stream, HandlerBase handler)
Parses the given XML InputStream using the given SAX event handler.
void parse(String uri, HandlerBase handler)
Parses the contents of the given URI using the given SAX event handler.
void parse(InputStream stream, DefaultHandler handler, String systemId)
Parses the given XML InputStream using the given SAX event handler and system ID.
void parse(InputStream stream, HandlerBase handler, String systemId)
Parses the given XML InputStream using the given SAX event handler and system ID.
void parse(InputSource source, DefaultHandler handler)
Parses the given SAX InputSource using the given SAX event handler.
void parse(InputSource source, HandlerBase handler)
Parses the given SAX InputSource using the given SAX event handler.
void parse(String uri, DefaultHandler handler)
Parses the contents of the given URI using the given SAX event handler.
void parse(File file, DefaultHandler handler)
Parses the given XML file using the given SAX event handler.
void parse(File file, HandlerBase handler)
Parses the given XML file using the given SAX event handler.
void reset()
Resets the SAXParser to the same state is was in after its creation.
abstract void setProperty(String name, Object value)
Sets a property of the underlying SAX XMLReader.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected SAXParser ()

Since: API Level 1

Do-nothing constructor. Prevents instantiation. To be overridden by concrete subclasses.

Public Methods

public abstract Parser getParser ()

Since: API Level 1

Queries the underlying SAX Parser object.

Returns
  • the SAX Parser.
Throws
SAXException if a problem occurs.

public abstract Object getProperty (String name)

Since: API Level 1

Queries a property of the underlying SAX XMLReader.

Parameters
name the name of the property.
Returns
  • the value of the property.
Throws
SAXNotRecognizedException if the property is not known to the underlying SAX XMLReader.
SAXNotSupportedException if the property is known, but not supported by the underlying SAX XMLReader.

public abstract XMLReader getXMLReader ()

Since: API Level 1

Queries the underlying SAX XMLReader object.

Returns
  • the SAX XMLREader.
Throws
SAXException if a problem occurs.

public abstract boolean isNamespaceAware ()

Since: API Level 1

Reflects whether this SAXParser is namespace-aware.

Returns
  • true if the SAXParser is namespace-aware, or false otherwise.

public abstract boolean isValidating ()

Since: API Level 1

Reflects whether this SAXParser is validating.

Returns
  • true if the SAXParser is validating, or false otherwise.

public boolean isXIncludeAware ()

Since: API Level 1

Reflects whether this SAXParser is XInclude-aware.

Returns
  • true if the SAXParser is XInclude-aware, or false otherwise.
Throws
UnsupportedOperationException if the underlying implementation doesn't know about XInclude at all (backwards compatibility).

public void parse (InputStream stream, DefaultHandler handler)

Since: API Level 1

Parses the given XML InputStream using the given SAX event handler.

Parameters
stream the InputStream containing the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (InputStream stream, HandlerBase handler)

Since: API Level 1

Parses the given XML InputStream using the given SAX event handler.

Parameters
stream the InputStream containing the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (String uri, HandlerBase handler)

Since: API Level 1

Parses the contents of the given URI using the given SAX event handler.

Parameters
uri the URI pointing to the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (InputStream stream, DefaultHandler handler, String systemId)

Since: API Level 1

Parses the given XML InputStream using the given SAX event handler and system ID.

Parameters
stream the InputStream containing the XML document.
handler the SAX handler.
systemId the system ID.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (InputStream stream, HandlerBase handler, String systemId)

Since: API Level 1

Parses the given XML InputStream using the given SAX event handler and system ID.

Parameters
stream the InputStream containing the XML document.
handler the SAX handler.
systemId the system ID.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (InputSource source, DefaultHandler handler)

Since: API Level 1

Parses the given SAX InputSource using the given SAX event handler.

Parameters
source the SAX InputSource containing the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (InputSource source, HandlerBase handler)

Since: API Level 1

Parses the given SAX InputSource using the given SAX event handler.

Parameters
source the SAX InputSource containing the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (String uri, DefaultHandler handler)

Since: API Level 1

Parses the contents of the given URI using the given SAX event handler.

Parameters
uri the URI pointing to the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (File file, DefaultHandler handler)

Since: API Level 1

Parses the given XML file using the given SAX event handler.

Parameters
file the file containing the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void parse (File file, HandlerBase handler)

Since: API Level 1

Parses the given XML file using the given SAX event handler.

Parameters
file the file containing the XML document.
handler the SAX handler.
Throws
SAXException if a problem occurs during SAX parsing.
IOException if a general IO problem occurs.

public void reset ()

Since: API Level 1

Resets the SAXParser to the same state is was in after its creation.

public abstract void setProperty (String name, Object value)

Since: API Level 1

Sets a property of the underlying SAX XMLReader.

Parameters
name the name of the property.
value the value of the property.
Throws
SAXNotRecognizedException if the property is not known to the underlying SAX XMLReader.
SAXNotSupportedException if the property is known, but not supported by the underlying SAX XMLReader.