FileDocCategorySizeDatePackage
DocumentBuilder.javaAPI DocAndroid 1.5 API7863Wed May 06 22:41:06 BST 2009javax.xml.parsers

DocumentBuilder

public abstract class DocumentBuilder extends Object
Defines a bridge from XML sources (files, stream etc.) to DOM trees. Can be used for easily obtaining a {@link org.w3c.dom.Document} for the input. The class itself is abstract. The class {@link DocumentBuilderFactory} is able to provide instances (of concrete subclasses known to the system).
since
Android 1.0

Fields Summary
Constructors Summary
protected DocumentBuilder()
Do-nothing constructor. Prevents instantiation. To be overridden by concrete subclasses.

since
Android 1.0

        // Does nothing.
    
Methods Summary
public abstract org.w3c.dom.DOMImplementationgetDOMImplementation()
Queries the DOM implementation this {@code DocumentBuilder} is working on.

return
the DOM implementation
since
Android 1.0

public abstract booleanisNamespaceAware()
Queries whether the {@code DocumentBuilder} has namespace support enabled.

return
{@code true} if namespaces are turned on, {@code false} otherwise.
since
Android 1.0

public abstract booleanisValidating()
Queries whether the {@code DocumentBuilder} has validation support enabled.

return
{@code true} if validation is turned on, {@code false} otherwise.
since
Android 1.0

public booleanisXIncludeAware()
Queries whether the {@code DocumentBuilder} has XInclude support enabled.

return
{@code true} if XInclude support is turned on, {@code false} otherwise.
throws
UnsupportedOperationException if the underlying implementation doesn't support XInclude.
since
Android 1.0

        throw new UnsupportedOperationException();
    
public abstract org.w3c.dom.DocumentnewDocument()
Creates a new, empty document, serving as the starting point for a DOM tree.

return
the document.
since
Android 1.0

public org.w3c.dom.Documentparse(java.lang.String uri)
Parses an XML input stream from a given URI and builds a DOM tree from it.

param
uri the URI to fetch the XML stream from.
return
the document element that represents the root of the DOM tree.
throws
SAXException if the XML parsing fails.
throws
IOException if an input/output error occurs.
since
Android 1.0

        if (uri == null) {
            throw new IllegalArgumentException();
        }
        
        return parse(new InputSource(uri));
    
public abstract org.w3c.dom.Documentparse(org.xml.sax.InputSource source)
Parses an XML input source and builds a DOM tree from it.

param
source the input source to parse.
return
the document element that represents the root of the DOM tree.
throws
SAXException if the XML parsing fails.
throws
IOException if an input/output error occurs.
since
Android 1.0

public org.w3c.dom.Documentparse(java.io.File file)
Parses a given XML file and builds a DOM tree from it.

param
file the file to be parsed.
return
the document element that represents the root of the DOM tree.
throws
SAXException if the XML parsing fails.
throws
IOException if an input/output error occurs.
since
Android 1.0

        if (file == null) {
            throw new IllegalArgumentException();
        }
        
        return parse(new BufferedInputStream(new FileInputStream(file), 8192));
    
public org.w3c.dom.Documentparse(java.io.InputStream stream)
Parses a given XML input stream and builds a DOM tree from it.

param
stream the stream to be parsed.
return
the document element that represents the root of the DOM tree.
throws
SAXException if the XML parsing fails.
throws
IOException if an input/output error occurs.
since
Android 1.0

        if (stream == null) {
            throw new IllegalArgumentException();
        }
        
        return parse(new InputSource(stream));
    
public org.w3c.dom.Documentparse(java.io.InputStream stream, java.lang.String systemId)
Parses a given XML input stream and builds a DOM tree from it.

param
stream the stream to be parsed.
param
systemId the base for resolving relative URIs.
return
the document element that represents the root of the DOM tree.
throws
SAXException if the XML parsing fails.
throws
IOException if an input/output error occurs.
since
Android 1.0

        if (stream == null) {
            throw new IllegalArgumentException();
        }
        
        InputSource source = new InputSource(stream);
        source.setSystemId(systemId);
        return parse(source);
    
public voidreset()
Resets the DocumentBuilder to the same state is was in after its creation.

since
Android 1.0

        // Do nothing.
    
public abstract voidsetEntityResolver(org.xml.sax.EntityResolver resolver)
Sets the {@link EntityResolver} used for resolving entities encountered during the parse process. Passing {@code null} results in the {@code DocumentBuilder}'s own {@code EntityResolver} being used.

param
resolver the {@code EntityResolver} to use, or null for the built-in one.
since
Android 1.0

public abstract voidsetErrorHandler(org.xml.sax.ErrorHandler handler)
Sets the {@link ErrorHandler} used for dealing with errors encountered during the parse process. Passing {@code null} results in the {@code DocumentBuilder}'s own {@code ErrorHandler} being used.

param
handler the {@code ErrorHandler} to use, or {@code null} for the built-in one.
since
Android 1.0