javax.xml.parsers
Class DocumentBuilderFactory

java.lang.Object
  |
  +--javax.xml.parsers.DocumentBuilderFactory

public abstract class DocumentBuilderFactory
extends java.lang.Object

Responsible for creating new DOM parsers

Normally, users will create a DOM parser as follows:


 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 DocumentBuilder parser = factory.newDocumentBuilder();
 Document doc = parser.parse(myInputSource);
 

DocumentBuilderFactory uses the system property javax.xml.parsers.XmlDocumentParserFactory to find the class to load. So you can change the parser by calling:


 System.setProperty("javax.xml.parsers.XmlDocumentParserFactory",
                    "com.foo.myFactory");
 


Constructor Summary
DocumentBuilderFactory()
           
 
Method Summary
abstract  java.lang.Object getAttribute(java.lang.String name)
          Returns an implementation-specific attributes.
 boolean isCoalescing()
          Returns true if the returned DocumentBuilder will combine Text and CDATA nodes into single text nodes.
 boolean isExpandEntityReferences()
          Returns true if the returned parser will expand entity reference nodes.
 boolean isIgnoringComments()
          Returns true if the parser will ignore comments.
 boolean isIgnoringElementContentWhitespace()
          Returns true if the parser will ignore ignorable-whitespace
 boolean isNamespaceAware()
          Returns true if the parser is namespace-aware
 boolean isValidating()
          Returns true if the parser is validating
abstract  DocumentBuilder newDocumentBuilder()
          Creates a new DocumentBuilder()
static DocumentBuilderFactory newInstance()
          Returns a new DocumentBuilderFactory instance based on the javax.xml.parsers.DocumentBuilderFactory system property.
abstract  void setAttribute(java.lang.String name, java.lang.Object value)
          Sets an implementation-specific attributes.
 void setCoalescing(boolean isCoalescing)
          Sets true if the returned DocumentBuilder should combine Text and CDATA nodes into single text nodes.
 void setExpandEntityReferences(boolean expand)
          Set true if the returned parser should expand entity reference nodes.
 void setIgnoringComments(boolean ignore)
          Set true if the parser should ignore comments
 void setIgnoringElementContentWhitespace(boolean ignore)
          Set true if the parser should ignore ignorable-whitespace
 void setNamespaceAware(boolean namespaceAware)
          Set true if the parser should be namespace-aware
 void setValidating(boolean validating)
          Set true if the parser should be validating-aware
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentBuilderFactory

public DocumentBuilderFactory()
Method Detail

getAttribute

public abstract java.lang.Object getAttribute(java.lang.String name)
                                       throws java.lang.IllegalArgumentException
Returns an implementation-specific attributes.
Parameters:
name - the name of the attribute

setAttribute

public abstract void setAttribute(java.lang.String name,
                                  java.lang.Object value)
                           throws java.lang.IllegalArgumentException
Sets an implementation-specific attributes.
Parameters:
name - the name of the attribute
value - the value of the attribute

isCoalescing

public boolean isCoalescing()
Returns true if the returned DocumentBuilder will combine Text and CDATA nodes into single text nodes.

setCoalescing

public void setCoalescing(boolean isCoalescing)
Sets true if the returned DocumentBuilder should combine Text and CDATA nodes into single text nodes.

isExpandEntityReferences

public boolean isExpandEntityReferences()
Returns true if the returned parser will expand entity reference nodes.

setExpandEntityReferences

public void setExpandEntityReferences(boolean expand)
Set true if the returned parser should expand entity reference nodes.

isIgnoringComments

public boolean isIgnoringComments()
Returns true if the parser will ignore comments.

setIgnoringComments

public void setIgnoringComments(boolean ignore)
Set true if the parser should ignore comments

isIgnoringElementContentWhitespace

public boolean isIgnoringElementContentWhitespace()
Returns true if the parser will ignore ignorable-whitespace

setIgnoringElementContentWhitespace

public void setIgnoringElementContentWhitespace(boolean ignore)
Set true if the parser should ignore ignorable-whitespace

isNamespaceAware

public boolean isNamespaceAware()
Returns true if the parser is namespace-aware

setNamespaceAware

public void setNamespaceAware(boolean namespaceAware)
Set true if the parser should be namespace-aware

isValidating

public boolean isValidating()
Returns true if the parser is validating

setValidating

public void setValidating(boolean validating)
Set true if the parser should be validating-aware

newInstance

public static DocumentBuilderFactory newInstance()
                                          throws FactoryConfigurationError
Returns a new DocumentBuilderFactory instance based on the javax.xml.parsers.DocumentBuilderFactory system property.
  1. System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
  2. META-INF/services/javax.xml.parsers.DocumentBuilderFactory
  3. $JAVA_HOME/lib/jaxp.properties
  4. com.caucho.xml.parsers.XmlDocumentBuilderFactory

newDocumentBuilder

public abstract DocumentBuilder newDocumentBuilder()
                                            throws ParserConfigurationException
Creates a new DocumentBuilder()