FileDocCategorySizeDatePackage
DocumentBuilderFactory.javaAPI DocAndroid 1.5 API12899Wed May 06 22:41:06 BST 2009javax.xml.parsers

DocumentBuilderFactory

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

Fields Summary
private boolean
coalesce
private boolean
expandEntityReferences
private boolean
ignoreComments
private boolean
ignoreElementContentWhitespace
private boolean
namespaceAware
private boolean
validate
Constructors Summary
protected DocumentBuilderFactory()
Do-nothing constructor. To be overridden by concrete document builders.

since
Android 1.0

        // Does nothing.
    
Methods Summary
public abstract java.lang.ObjectgetAttribute(java.lang.String name)
Queries an attribute from the underlying implementation.

param
name the name of the attribute.
return
the value of the attribute.
throws
IllegalArgumentException if the argument is unknown to the underlying implementation.
since
Android 1.0

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 DocumentBuilder} 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
IllegalArgumentException if the feature is unknown to the underlying implementation.
throws
ParserConfigurationException if the feature is known, but not supported.
since
Android 1.0

public booleanisCoalescing()
Queries whether the factory is configured to deliver parsers that convert CDATA nodes to text nodes and melt them with neighboring nodes. This is called "coalescing".

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

        return coalesce;
    
public booleanisExpandEntityReferences()
Queries whether the factory is configured to deliver parsers that expand entity references.

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

        return expandEntityReferences;
    
public booleanisIgnoringComments()
Queries whether the factory is configured to deliver parsers that ignore comments.

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

        return ignoreComments;
    
public booleanisIgnoringElementContentWhitespace()
Queries whether the factory is configured to deliver parsers that ignore whitespace in elements.

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

        return ignoreElementContentWhitespace;
    
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 validate;
    
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 abstract javax.xml.parsers.DocumentBuildernewDocumentBuilder()
Creates a new {@link DocumentBuilder} that matches the current configuration of the factory.

return
the DocumentBuilder.
throws
ParserConfigurationException if no matching {@code DocumentBuilder} could be found.
since
Android 1.0

public static javax.xml.parsers.DocumentBuilderFactorynewInstance()
Creates a new DocumentBuilderFactory that can be configured and then be used for creating DocumentBuilder objects. The method first checks the value of the {@code DocumentBuilderFactory} 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 DocumentBuilderFactory.
throws
FactoryConfigurationError if no {@code DocumentBuilderFactory} 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.DocumentBuilderFactory");
        if (factory != null) {
            try {
                return (DocumentBuilderFactory) Class.forName(factory)
                        .newInstance();
            } catch (Exception ex) {
                // Ignore.
            }
        }

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

        throw new FactoryConfigurationError(
                "Cannot create DocumentBuilderFactory");
    
public abstract voidsetAttribute(java.lang.String name, java.lang.Object value)
Sets an attribute in the underlying implementation.

param
name the name of the attribute.
param
value the value of the attribute.
throws
IllegalArgumentException if the argument is unknown to the underlying implementation.
since
Android 1.0

public voidsetCoalescing(boolean value)
Determines whether the factory is configured to deliver parsers that convert CDATA nodes to text nodes and melt them with neighboring nodes. This is called "coalescing".

param
value turns coalescing on or off.
since
Android 1.0

        coalesce = value;
    
public voidsetExpandEntityReferences(boolean value)
Determines whether the factory is configured to deliver parsers that expands entity references.

param
value turns entity reference expansion on or off.
since
Android 1.0

        expandEntityReferences = value;
    
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 DocumentBuilder} 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 set 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 value of the feature.
throws
ParserConfigurationException if the feature is unknown to the underlying implementation.
since
Android 1.0

public voidsetIgnoringComments(boolean value)
Determines whether the factory is configured to deliver parsers that ignore comments.

param
value turns comment ignorance on or off.
since
Android 1.0

        ignoreComments = value;
    
public voidsetIgnoringElementContentWhitespace(boolean value)
Determines whether the factory is configured to deliver parsers that ignores element whitespace.

param
value turns element whitespace ignorance on or off.
since
Android 1.0

        ignoreElementContentWhitespace = value;
    
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

        validate = 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();