FileDocCategorySizeDatePackage
SAXParserFactory.javaAPI DocAndroid 1.5 API9803Wed May 06 22:41:06 BST 2009javax.xml.parsers

SAXParserFactory

public abstract class SAXParserFactory extends Object
Provides a factory for {@link SAXParser} instances. The class first needs to be instantiated using the {@link #newInstance()} method. The instance can be configured as desired. A call to its {@link #newSAXParser()} then provides a {@code SAXParser} instance matching this configuration, if possible.
since
Android 1.0

Fields Summary
private boolean
namespaceAware
private boolean
validating
private boolean
xincludeAware
Constructors Summary
protected SAXParserFactory()
Do-nothing constructor. Prevents instantiation. To be overridden by concrete subclasses.

since
Android 1.0

        // Does nothing.
    
Methods Summary
public abstract booleangetFeature(java.lang.String name)
Queries a feature from the underlying implementation.

param
name The name of the feature. The default Android implementation of {@link SAXParser} supports only the following three features:
{@code http://xml.org/sax/features/namespaces}
Queries the state of namespace-awareness.
{@code http://xml.org/sax/features/namespace-prefixes}
Queries the state of namespace prefix processing
{@code 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.
return
the status of the feature.
throws
ParserConfigurationException if no {@code SAXParser} matching the given criteria is available.
throws
SAXNotRecognizedException if the given feature is not known to the underlying implementation.
throws
SAXNotSupportedException if the given features is known, but not supported by the underlying implementation.
since
Android 1.0

public booleanisNamespaceAware()
Queries whether the factory is configured to deliver parsers that are namespace-aware.

return
{@code true} if namespace-awareness is desired, {@code false} otherwise.
since
Android 1.0

        return namespaceAware;
    
public booleanisValidating()
Queries whether the factory is configured to deliver parsers that are validating.

return
{@code true} if validating is desired, {@code false} otherwise.
since
Android 1.0

        return validating;
    
public booleanisXIncludeAware()
Queries whether the factory is configured to deliver parsers that are XInclude-aware.

return
{@code true} if XInclude-awareness is desired, {@code false} otherwise.
since
Android 1.0

        throw new UnsupportedOperationException();
    
public static javax.xml.parsers.SAXParserFactorynewInstance()
Creates a new {@code SAXParserFactory} that can be configured and then be used for creating {@link SAXParser} objects. The method first checks the value of the {@code SAXParserFactory} property. If this is non-{@code 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 {@code null}, the system's default factory implementation is returned.

return
the {@code SAXParserFactory}.
throws
FactoryConfigurationError if no {@code SAXParserFactory} can be created.
since
Android 1.0

        // TODO Properties file and META-INF case missing here. See spec.
        String factory = System
                .getProperty("javax.xml.parsers.SAXParserFactory");
        if (factory != null) {
            try {
                return (SAXParserFactory) Class.forName(factory).newInstance();
            } catch (Exception ex) {
                throw new FactoryConfigurationError(factory);
            }
        }

        try {
            return new SAXParserFactoryImpl();
        } catch (Exception ex) {
            // Ignore.
        }

        throw new FactoryConfigurationError("Cannot create SAXParserFactory");
    
public abstract javax.xml.parsers.SAXParsernewSAXParser()
Creates a new {@link SAXParser} that matches the current configuration of the factory.

return
the {@code SAXParser}.
throws
ParserConfigurationException if no matching {@code SAXParser} could be found.
throws
SAXException if creating the {@code SAXParser} failed due to some other reason.
since
Android 1.0

public abstract voidsetFeature(java.lang.String name, boolean value)
Sets a feature in the underlying implementation.

param
name the name of the feature. The default Android implementation of {@link SAXParser} supports only the following three features:
{@code http://xml.org/sax/features/namespaces}
Sets the state of namespace-awareness.
{@code http://xml.org/sax/features/namespace-prefixes}
Sets the state of namespace prefix processing
{@code 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.
param
value the status of the feature.
throws
ParserConfigurationException if no {@code SAXParser} matching the given criteria is available.
throws
SAXNotRecognizedException if the given feature is not known to the underlying implementation.
throws
SAXNotSupportedException if the given features is known, but not supported by the underlying implementation.
since
Android 1.0

public voidsetNamespaceAware(boolean value)
Determines whether the factory is configured to deliver parsers that are namespace-aware.

param
value turns namespace-awareness on or off.
since
Android 1.0

        namespaceAware = value;
    
public voidsetValidating(boolean value)
Determines whether the factory is configured to deliver parsers that are validating.

param
value turns validation on or off.
since
Android 1.0

        validating = value;
    
public voidsetXIncludeAware(boolean value)
Determines whether the factory is configured to deliver parsers that are XInclude-aware.

param
value turns XInclude-awareness on or off.
since
Android 1.0

        throw new UnsupportedOperationException();