public abstract class

SAXParserFactory

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

Class Overview

Provides a factory for SAXParser instances. The class first needs to be instantiated using the newInstance() method. The instance can be configured as desired. A call to its newSAXParser() then provides a SAXParser instance matching this configuration, if possible.

Summary

Protected Constructors
SAXParserFactory()
Do-nothing constructor.
Public Methods
abstract boolean getFeature(String name)
Queries a feature from the underlying implementation.
boolean isNamespaceAware()
Queries whether the factory is configured to deliver parsers that are namespace-aware.
boolean isValidating()
Queries whether the factory is configured to deliver parsers that are validating.
boolean isXIncludeAware()
Queries whether the factory is configured to deliver parsers that are XInclude-aware.
static SAXParserFactory newInstance()
Creates a new SAXParserFactory that can be configured and then be used for creating SAXParser objects.
abstract SAXParser newSAXParser()
Creates a new SAXParser that matches the current configuration of the factory.
abstract void setFeature(String name, boolean value)
Sets a feature in the underlying implementation.
void setNamespaceAware(boolean value)
Determines whether the factory is configured to deliver parsers that are namespace-aware.
void setValidating(boolean value)
Determines whether the factory is configured to deliver parsers that are validating.
void setXIncludeAware(boolean value)
Determines whether the factory is configured to deliver parsers that are XInclude-aware.
[Expand]
Inherited Methods
From class java.lang.Object

Protected Constructors

protected SAXParserFactory ()

Since: API Level 1

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

Public Methods

public abstract boolean getFeature (String name)

Since: API Level 1

Queries a feature from the underlying implementation.

Parameters
name The name of the feature. The default Android implementation of SAXParser supports only the following three features:
http://xml.org/sax/features/namespaces
Queries the state of namespace-awareness.
http://xml.org/sax/features/namespace-prefixes
Queries the state of namespace prefix processing
http://xml.org/sax/features/validation
Queries the state of validation.
Note that despite the ability to query the validation feature, there is currently no validating parser available. Also note that currently either namespaces or namespace prefixes can be enabled, but not both at the same time.
Returns
  • the status of the feature.
Throws
ParserConfigurationException if no SAXParser matching the given criteria is available.
SAXNotRecognizedException if the given feature is not known to the underlying implementation.
SAXNotSupportedException if the given features is known, but not supported by the underlying implementation.

public boolean isNamespaceAware ()

Since: API Level 1

Queries whether the factory is configured to deliver parsers that are namespace-aware.

Returns
  • true if namespace-awareness is desired, false otherwise.

public boolean isValidating ()

Since: API Level 1

Queries whether the factory is configured to deliver parsers that are validating.

Returns
  • true if validating is desired, false otherwise.

public boolean isXIncludeAware ()

Since: API Level 1

Queries whether the factory is configured to deliver parsers that are XInclude-aware.

Returns
  • true if XInclude-awareness is desired, false otherwise.

public static SAXParserFactory newInstance ()

Since: API Level 1

Creates a new SAXParserFactory that can be configured and then be used for creating SAXParser objects. The method first checks the value of the SAXParserFactory property. If this is non-null, it is assumed to be the name of a class that serves as the factory. The class is instantiated, and the instance is returned. If the property value is null, the system's default factory implementation is returned.

Returns
  • the SAXParserFactory.
Throws
FactoryConfigurationError if no SAXParserFactory can be created.

public abstract SAXParser newSAXParser ()

Since: API Level 1

Creates a new SAXParser that matches the current configuration of the factory.

Returns
  • the SAXParser.
Throws
ParserConfigurationException if no matching SAXParser could be found.
SAXException if creating the SAXParser failed due to some other reason.

public abstract void setFeature (String name, boolean value)

Since: API Level 1

Sets a feature in the underlying implementation.

Parameters
name the name of the feature. The default Android implementation of SAXParser supports only the following three features:
http://xml.org/sax/features/namespaces
Sets the state of namespace-awareness.
http://xml.org/sax/features/namespace-prefixes
Sets the state of namespace prefix processing
http://xml.org/sax/features/validation
Sets the state of validation.
Note that despite the ability to query the validation feature, there is currently no validating parser available. Also note that currently either namespaces or namespace prefixes can be enabled, but not both at the same time.
value the status of the feature.
Throws
ParserConfigurationException if no SAXParser matching the given criteria is available.
SAXNotRecognizedException if the given feature is not known to the underlying implementation.
SAXNotSupportedException if the given features is known, but not supported by the underlying implementation.

public void setNamespaceAware (boolean value)

Since: API Level 1

Determines whether the factory is configured to deliver parsers that are namespace-aware.

Parameters
value turns namespace-awareness on or off.

public void setValidating (boolean value)

Since: API Level 1

Determines whether the factory is configured to deliver parsers that are validating.

Parameters
value turns validation on or off.

public void setXIncludeAware (boolean value)

Since: API Level 1

Determines whether the factory is configured to deliver parsers that are XInclude-aware.

Parameters
value turns XInclude-awareness on or off.