Android
javax.xml.parsers
public abstract class

javax.xml.parsers.DocumentBuilder

java.lang.Object
javax.xml.parsers.DocumentBuilder

Defines a bridge from XML sources (files, stream etc.) to DOM trees. Can be used for easily obtaining a Document for the input. The class itself is abstract. The class DocumentBuilderFactory is able to provide instances (of concrete subclasses known to the system).

Summary

Protected Constructors

            DocumentBuilder()
Do-nothing constructor.

Public Methods

abstract          DOMImplementation  getDOMImplementation()
Queries the DOM implementation this DocumentBuilder is working on.
abstract          boolean  isNamespaceAware()
Queries whether the DocumentBuilder has namespaces enabled.
abstract          boolean  isValidating()
Queries whether the DocumentBuilder has validating enabled.
          boolean  isXIncludeAware()
Queries whether the DocumentBuilder has XInclude support enabled.
abstract          Document  newDocument()
Creates a new document, serving as the starting point for a DOM tree.
          Document  parse(InputStream stream)
Parses a given XML input stream and builds a DOM tree from it.
          Document  parse(String uri)
Parses an XML input stream from a given URI and builds a DOM tree from it.
          Document  parse(File file)
Parses a given XML file and builds a DOM tree from it.
abstract          Document  parse(InputSource source)
Parses an XML input source and builds a DOM tree from it.
          Document  parse(InputStream stream, String systemId)
Parses a given XML input stream and builds a DOM tree from it.
          void  reset()
Resets the DocumentBuilder to the same state is was in after its creation.
abstract          void  setEntityResolver(EntityResolver resolver)
Sets the EntityResolver used for resolving entities encountered during the parse process.
abstract          void  setErrorHandler(ErrorHandler handler)
Sets the ErrorHandler used for dealing with errors encountered during the parse process.
Methods inherited from class java.lang.Object

Details

Protected Constructors

protected DocumentBuilder()

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

Public Methods

public abstract DOMImplementation getDOMImplementation()

Queries the DOM implementation this DocumentBuilder is working on.

Returns

  • The DOM implementation

public abstract boolean isNamespaceAware()

Queries whether the DocumentBuilder has namespaces enabled.

Returns

  • true if namespaces are turned on, false otherwise.

public abstract boolean isValidating()

Queries whether the DocumentBuilder has validating enabled.

Returns

  • true if validating is turned on, false otherwise.

public boolean isXIncludeAware()

Queries whether the DocumentBuilder has XInclude support enabled.

Returns

  • true if XInclude support is turned on, false otherwise.

Throws

UnsupportedOperationException when the underlying imlementation doesn't support XInclude.

public abstract Document newDocument()

Creates a new document, serving as the starting point for a DOM tree.

Returns

  • The document.

public Document parse(InputStream stream)

Parses a given XML input stream and builds a DOM tree from it.

Parameters

stream The stream to be parsed.

Returns

  • The document element that represents the root of the DOM tree.

Throws

SAXException if the XML parsing fails.
IOException if an input/output error occurs.

public Document parse(String uri)

Parses an XML input stream from a given URI and builds a DOM tree from it.

Parameters

uri The URI to fetch the XML stream from.

Returns

  • The document element that represents the root of the DOM tree.

Throws

SAXException if the XML parsing fails.
IOException if an input/output error occurs.

public Document parse(File file)

Parses a given XML file and builds a DOM tree from it.

Parameters

file The file to be parsed.

Returns

  • The document element that represents the root of the DOM tree.

Throws

SAXException if the XML parsing fails.
IOException if an input/output error occurs.

public abstract Document parse(InputSource source)

Parses an XML input source and builds a DOM tree from it.

Parameters

source The input source to parse.

Returns

  • The document element that represents the root of the DOM tree.

Throws

SAXException if the XML parsing fails.
IOException if an input/output error occurs.

public Document parse(InputStream stream, String systemId)

Parses a given XML input stream and builds a DOM tree from it.

Parameters

stream The stream to be parsed.
systemId The base for resolving relative URIs.

Returns

  • The document element that represents the root of the DOM tree.

Throws

SAXException if the XML parsing fails.
IOException if an input/output error occurs.

public void reset()

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

public abstract void setEntityResolver(EntityResolver resolver)

Sets the EntityResolver used for resolving entities encountered during the parse process. Passing null results in the DocumentBuilder's own EntityResolver being used.

Parameters

resolver The EntityResolver to use, or null for the built-in one.

public abstract void setErrorHandler(ErrorHandler handler)

Sets the ErrorHandler used for dealing with errors encountered during the parse process. Passing null results in the DocumentBuilder's own ErrorHandler being used.

Parameters

handler The ErrorHandler to use, or null for the built-in one.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48