Java Doc for DocumentBuilderFactory.java in  » 6.0-JDK-Core » xml » javax » xml » parsers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » xml » javax.xml.parsers 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.xml.parsers.DocumentBuilderFactory

DocumentBuilderFactory
abstract public class DocumentBuilderFactory (Code)
Defines a factory API that enables applications to obtain a parser that produces DOM object trees from XML documents.
author:
   Jeff Suttor
author:
   Neeraj Bajaj
version:
   $Revision: 1.5 $, $Date: 2005/11/03 19:34:14 $



Constructor Summary
protected  DocumentBuilderFactory()
    

Protected constructor to prevent instantiation.


Method Summary
abstract public  ObjectgetAttribute(String name)
     Allows the user to retrieve specific attributes on the underlying implementation.
Parameters:
  name - The name of the attribute.
abstract public  booleangetFeature(String name)
    

Get the state of the named feature.

Feature names are fully qualified java.net.URI s. Implementations may define their own features. An ParserConfigurationException is thrown if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support the feature. It is possible for an DocumentBuilderFactory to expose a feature value but be unable to change its state.


Parameters:
  name - Feature name.
public  SchemagetSchema()
     Gets the Schema object specified through the DocumentBuilderFactory.setSchema(Schema schema) method.
public  booleanisCoalescing()
     Indicates whether or not the factory is configured to produce parsers which converts CDATA nodes to Text nodes and appends it to the adjacent (if any) Text node.
public  booleanisExpandEntityReferences()
     Indicates whether or not the factory is configured to produce parsers which expand entity reference nodes.
public  booleanisIgnoringComments()
     Indicates whether or not the factory is configured to produce parsers which ignores comments.
public  booleanisIgnoringElementContentWhitespace()
     Indicates whether or not the factory is configured to produce parsers which ignore ignorable whitespace in element content.
public  booleanisNamespaceAware()
     Indicates whether or not the factory is configured to produce parsers which are namespace aware.
public  booleanisValidating()
     Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse.
public  booleanisXIncludeAware()
    
abstract public  DocumentBuildernewDocumentBuilder()
     Creates a new instance of a javax.xml.parsers.DocumentBuilder using the currently configured parameters.
public static  DocumentBuilderFactorynewInstance()
     Obtain a new instance of a DocumentBuilderFactory.
public static  DocumentBuilderFactorynewInstance(String factoryClassName, ClassLoader classLoader)
    

Obtain a new instance of a DocumentBuilderFactory from class name. This function is useful when there are multiple providers in the classpath. It gives more control to the application as it can specify which provider should be loaded.

Once an application has obtained a reference to a DocumentBuilderFactory it can use the factory to configure and obtain parser instances.

Tip for Trouble-shooting

Setting the jaxp.debug system property will cause this method to print a lot of debug messages to System.err about what it is doing and where it is looking at.

If you have problems try:

 java -Djaxp.debug=1 YourProgram ....
 

Parameters:
  factoryClassName - fully qualified factory class name that provides implementation of javax.xml.parsers.DocumentBuilderFactory.
Parameters:
  classLoader - ClassLoader used to load the factory class.
abstract public  voidsetAttribute(String name, Object value)
     Allows the user to set specific attributes on the underlying implementation.
public  voidsetCoalescing(boolean coalescing)
     Specifies that the parser produced by this code will convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node.
public  voidsetExpandEntityReferences(boolean expandEntityRef)
     Specifies that the parser produced by this code will expand entity reference nodes.
abstract public  voidsetFeature(String name, boolean value)
    

Set a feature for this DocumentBuilderFactory and DocumentBuilders created by this factory.

Feature names are fully qualified java.net.URI s.

public  voidsetIgnoringComments(boolean ignoreComments)
    

Specifies that the parser produced by this code will ignore comments.

public  voidsetIgnoringElementContentWhitespace(boolean whitespace)
     Specifies that the parsers created by this factory must eliminate whitespace in element content (sometimes known loosely as 'ignorable whitespace') when parsing XML documents (see XML Rec 2.10).
public  voidsetNamespaceAware(boolean awareness)
     Specifies that the parser produced by this code will provide support for XML namespaces.
public  voidsetSchema(Schema schema)
    

Set the Schema to be used by parsers created from this factory.

When a Schema is non-null, a parser will use a validator created from it to validate documents before it passes information down to the application.

When errors are found by the validator, the parser is responsible to report them to the user-specified org.xml.sax.ErrorHandler (or if the error handler is not set, ignore them or throw them), just like any other errors found by the parser itself. In other words, if the user-specified org.xml.sax.ErrorHandler is set, it must receive those errors, and if not, they must be treated according to the implementation specific default error handling rules.

A validator may modify the outcome of a parse (for example by adding default values that were missing in documents), and a parser is responsible to make sure that the application will receive modified DOM trees.

public  voidsetValidating(boolean validating)
     Specifies that the parser produced by this code will validate documents as they are parsed.
public  voidsetXIncludeAware(boolean state)
    


Constructor Detail
DocumentBuilderFactory
protected DocumentBuilderFactory()(Code)

Protected constructor to prevent instantiation. Use DocumentBuilderFactory.newInstance() .





Method Detail
getAttribute
abstract public Object getAttribute(String name) throws IllegalArgumentException(Code)
Allows the user to retrieve specific attributes on the underlying implementation.
Parameters:
  name - The name of the attribute. value The value of the attribute.
throws:
  IllegalArgumentException - thrown if the underlyingimplementation doesn't recognize the attribute.



getFeature
abstract public boolean getFeature(String name) throws ParserConfigurationException(Code)

Get the state of the named feature.

Feature names are fully qualified java.net.URI s. Implementations may define their own features. An ParserConfigurationException is thrown if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support the feature. It is possible for an DocumentBuilderFactory to expose a feature value but be unable to change its state.


Parameters:
  name - Feature name. State of the named feature.
throws:
  ParserConfigurationException - if this DocumentBuilderFactoryor the DocumentBuilders it creates cannot support this feature.



getSchema
public Schema getSchema()(Code)
Gets the Schema object specified through the DocumentBuilderFactory.setSchema(Schema schema) method. the Schema object that was last set throughthe DocumentBuilderFactory.setSchema(Schema) method, or nullif the method was not invoked since a DocumentBuilderFactoryis created.
throws:
  UnsupportedOperationException - When implementation does notoverride this method.
since:
   1.5



isCoalescing
public boolean isCoalescing()(Code)
Indicates whether or not the factory is configured to produce parsers which converts CDATA nodes to Text nodes and appends it to the adjacent (if any) Text node. true if the factory is configured to produce parserswhich converts CDATA nodes to Text nodes and appends it tothe adjacent (if any) Text node; false otherwise.



isExpandEntityReferences
public boolean isExpandEntityReferences()(Code)
Indicates whether or not the factory is configured to produce parsers which expand entity reference nodes. true if the factory is configured to produce parserswhich expand entity reference nodes; false otherwise.



isIgnoringComments
public boolean isIgnoringComments()(Code)
Indicates whether or not the factory is configured to produce parsers which ignores comments. true if the factory is configured to produce parserswhich ignores comments; false otherwise.



isIgnoringElementContentWhitespace
public boolean isIgnoringElementContentWhitespace()(Code)
Indicates whether or not the factory is configured to produce parsers which ignore ignorable whitespace in element content. true if the factory is configured to produce parserswhich ignore ignorable whitespace in element content;false otherwise.



isNamespaceAware
public boolean isNamespaceAware()(Code)
Indicates whether or not the factory is configured to produce parsers which are namespace aware. true if the factory is configured to produce parsers whichare namespace aware; false otherwise.



isValidating
public boolean isValidating()(Code)
Indicates whether or not the factory is configured to produce parsers which validate the XML content during parse. true if the factory is configured to produce parserswhich validate the XML content during parse; false otherwise.



isXIncludeAware
public boolean isXIncludeAware()(Code)

Get state of XInclude processing.

current state of XInclude processing
throws:
  UnsupportedOperationException - When implementation does notoverride this method.
since:
   1.5



newDocumentBuilder
abstract public DocumentBuilder newDocumentBuilder() throws ParserConfigurationException(Code)
Creates a new instance of a javax.xml.parsers.DocumentBuilder using the currently configured parameters. A new instance of a DocumentBuilder.
throws:
  ParserConfigurationException - if a DocumentBuildercannot be created which satisfies the configuration requested.



newInstance
public static DocumentBuilderFactory newInstance()(Code)
Obtain a new instance of a DocumentBuilderFactory. This static method creates a new factory instance. This method uses the following ordered lookup procedure to determine the DocumentBuilderFactory implementation class to load:
  • Use the javax.xml.parsers.DocumentBuilderFactory system property.
  • Use the properties file "lib/jaxp.properties" in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to check for its existence. It is not possible to change the value of any property in jaxp.properties after it has been read for the first time.
  • Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API will look for a classname in the file META-INF/services/javax.xml.parsers.DocumentBuilderFactory in jars available to the runtime.
  • Platform default DocumentBuilderFactory instance.
Once an application has obtained a reference to a DocumentBuilderFactory it can use the factory to configure and obtain parser instances.

Tip for Trouble-shooting

Setting the jaxp.debug system property will cause this method to print a lot of debug messages to System.err about what it is doing and where it is looking at.

If you have problems loading DocumentBuilder s, try:

 java -Djaxp.debug=1 YourProgram ....
 
New instance of a DocumentBuilderFactory
throws:
  FactoryConfigurationError - if the implementation is notavailable or cannot be instantiated.



newInstance
public static DocumentBuilderFactory newInstance(String factoryClassName, ClassLoader classLoader)(Code)

Obtain a new instance of a DocumentBuilderFactory from class name. This function is useful when there are multiple providers in the classpath. It gives more control to the application as it can specify which provider should be loaded.

Once an application has obtained a reference to a DocumentBuilderFactory it can use the factory to configure and obtain parser instances.

Tip for Trouble-shooting

Setting the jaxp.debug system property will cause this method to print a lot of debug messages to System.err about what it is doing and where it is looking at.

If you have problems try:

 java -Djaxp.debug=1 YourProgram ....
 

Parameters:
  factoryClassName - fully qualified factory class name that provides implementation of javax.xml.parsers.DocumentBuilderFactory.
Parameters:
  classLoader - ClassLoader used to load the factory class. If null current Thread's context classLoader is used to load the factory class. New instance of a DocumentBuilderFactory
throws:
  FactoryConfigurationError - if factoryClassName is null, or the factory class cannot be loaded, instantiated.
See Also:   DocumentBuilderFactory.newInstance()
since:
   1.6



setAttribute
abstract public void setAttribute(String name, Object value) throws IllegalArgumentException(Code)
Allows the user to set specific attributes on the underlying implementation.
Parameters:
  name - The name of the attribute.
Parameters:
  value - The value of the attribute.
throws:
  IllegalArgumentException - thrown if the underlyingimplementation doesn't recognize the attribute.



setCoalescing
public void setCoalescing(boolean coalescing)(Code)
Specifies that the parser produced by this code will convert CDATA nodes to Text nodes and append it to the adjacent (if any) text node. By default the value of this is set to false
Parameters:
  coalescing - true if the parser produced will convert CDATA nodesto Text nodes and append it to the adjacent (if any)text node; false otherwise.



setExpandEntityReferences
public void setExpandEntityReferences(boolean expandEntityRef)(Code)
Specifies that the parser produced by this code will expand entity reference nodes. By default the value of this is set to true
Parameters:
  expandEntityRef - true if the parser produced will expand entityreference nodes; false otherwise.



setFeature
abstract public void setFeature(String name, boolean value) throws ParserConfigurationException(Code)

Set a feature for this DocumentBuilderFactory and DocumentBuilders created by this factory.

Feature names are fully qualified java.net.URI s. Implementations may define their own features. A ParserConfigurationException is thrown if this DocumentBuilderFactory or the DocumentBuilders it creates cannot support the feature. It is possible for a DocumentBuilderFactory to expose a feature value but be unable to change its state.

All implementations are required to support the javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING feature. When the feature is:


Parameters:
  name - Feature name.
Parameters:
  value - Is feature state true or false.
throws:
  ParserConfigurationException - if this DocumentBuilderFactory or the DocumentBuildersit creates cannot support this feature.
throws:
  NullPointerException - If the name parameter is null.



setIgnoringComments
public void setIgnoringComments(boolean ignoreComments)(Code)

Specifies that the parser produced by this code will ignore comments. By default the value of this is set to false .


Parameters:
  ignoreComments - boolean value to ignore comments during processing



setIgnoringElementContentWhitespace
public void setIgnoringElementContentWhitespace(boolean whitespace)(Code)
Specifies that the parsers created by this factory must eliminate whitespace in element content (sometimes known loosely as 'ignorable whitespace') when parsing XML documents (see XML Rec 2.10). Note that only whitespace which is directly contained within element content that has an element only content model (see XML Rec 3.2.1) will be eliminated. Due to reliance on the content model this setting requires the parser to be in validating mode. By default the value of this is set to false.
Parameters:
  whitespace - true if the parser created must eliminate whitespacein the element content when parsing XML documents;false otherwise.



setNamespaceAware
public void setNamespaceAware(boolean awareness)(Code)
Specifies that the parser produced by this code will provide support for XML namespaces. By default the value of this is set to false
Parameters:
  awareness - true if the parser produced will provide supportfor XML namespaces; false otherwise.



setSchema
public void setSchema(Schema schema)(Code)

Set the Schema to be used by parsers created from this factory.

When a Schema is non-null, a parser will use a validator created from it to validate documents before it passes information down to the application.

When errors are found by the validator, the parser is responsible to report them to the user-specified org.xml.sax.ErrorHandler (or if the error handler is not set, ignore them or throw them), just like any other errors found by the parser itself. In other words, if the user-specified org.xml.sax.ErrorHandler is set, it must receive those errors, and if not, they must be treated according to the implementation specific default error handling rules.

A validator may modify the outcome of a parse (for example by adding default values that were missing in documents), and a parser is responsible to make sure that the application will receive modified DOM trees.

Initialy, null is set as the Schema .

This processing will take effect even if the DocumentBuilderFactory.isValidating() method returns false.

It is an error to use the http://java.sun.com/xml/jaxp/properties/schemaSource property and/or the http://java.sun.com/xml/jaxp/properties/schemaLanguage property in conjunction with a Schema object. Such configuration will cause a ParserConfigurationException exception when the DocumentBuilderFactory.newDocumentBuilder() is invoked.

Note for implmentors

A parser must be able to work with any Schema implementation. However, parsers and schemas are allowed to use implementation-specific custom mechanisms as long as they yield the result described in the specification.


Parameters:
  schema - Schema to use or nullto remove a schema.
throws:
  UnsupportedOperationException - When implementation does notoverride this method.
since:
   1.5



setValidating
public void setValidating(boolean validating)(Code)
Specifies that the parser produced by this code will validate documents as they are parsed. By default the value of this is set to false.

Note that "the validation" here means a validating parser as defined in the XML recommendation. In other words, it essentially just controls the DTD validation. (except the legacy two properties defined in JAXP 1.2.)

To use modern schema languages such as W3C XML Schema or RELAX NG instead of DTD, you can configure your parser to be a non-validating parser by leaving the DocumentBuilderFactory.setValidating(boolean) method false, then use the DocumentBuilderFactory.setSchema(Schema) method to associate a schema to a parser.


Parameters:
  validating - true if the parser produced will validate documentsas they are parsed; false otherwise.



setXIncludeAware
public void setXIncludeAware(boolean state)(Code)

Set state of XInclude processing.

If XInclude markup is found in the document instance, should it be processed as specified in XML Inclusions (XInclude) Version 1.0.

XInclude processing defaults to false.


Parameters:
  state - Set XInclude processing to true orfalse
throws:
  UnsupportedOperationException - When implementation does notoverride this method.
since:
   1.5



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.