Top Description Fields Constructors Methods
org.dom4j

public Class DocumentFactory

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
org.dom4j.bean.BeanDocumentFactory, org.dom4j.datatype.DatatypeDocumentFactory, org.dom4j.datatype.DatatypeElementFactory, org.dom4j.dom.DOMDocumentFactory, org.dom4j.util.IndexedDocumentFactory, org.dom4j.util.NonLazyDocumentFactory, org.dom4j.util.UserDataDocumentFactory
Annotations
@SuppressWarnings:unused
Imports
java.io.IOException, .ObjectInputStream, .Serializable, java.util.List, .Map, org.dom4j.rule.Pattern, org.dom4j.tree.AbstractDocument, .DefaultAttribute, .DefaultCDATA, .DefaultComment, .DefaultDocument, .DefaultDocumentType, .DefaultElement, .DefaultEntity, .DefaultProcessingInstruction, .DefaultText, .QNameCache, org.dom4j.util.SimpleSingleton, .SingletonStrategy, org.dom4j.xpath.DefaultXPath, .XPathPattern, org.jaxen.VariableContext

DocumentFactory is a collection of factory methods to allow easy custom building of DOM4J trees. The default tree that is built uses a doubly linked tree. The tree built allows full XPath expressions from anywhere on the tree.
Author
James Strachan

Field Summary

Modifier and TypeField and Description
protected transient QNameCache
private static SingletonStrategy<DocumentFactory>
private Map<String, String>
xpathNamespaceURIs

Default namespace prefix → URI mappings for XPath expressions to use

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Attribute
createAttribute(Element owner, QName qname, String value)

public Attribute
createAttribute(Element owner, String name, String value)

public CDATA
public Comment
public DocumentType
createDocType(String name, String publicId, String systemId)

public Document
public Document

Returns:

DOCUMENT ME!
createDocument
(String
DOCUMENT ME!
encoding
)

DOCUMENT ME!

public Document
createDocument(Element rootElement)

public Element
public Element
public Element
createElement(String qualifiedName, String namespaceURI)

public Entity
public Namespace
public Pattern

Returns:

a new Pattern instance
createPattern
(String
is the XPath pattern expression to create
xpathPattern
)

createPattern parses the given XPath expression to create an XSLT style Patterninstance which can then be used in an XSLT processing model.

public ProcessingInstruction
public ProcessingInstruction
public QName
createQName(String localName, Namespace namespace)

public QName
createQName(String localName)

public QName
createQName(String name, String prefix, String uri)

public QName
createQName(String qualifiedName, String uri)

protected QNameCache

Returns:

DOCUMENT ME!
createQNameCache
()

Factory method to create the QNameCache.

private static SingletonStrategy<DocumentFactory>
protected static DocumentFactory

Returns:

a new singleton instance.
createSingleton
(String
is the name of the DocumentFactory class to use
className
)

createSingleton creates the singleton instance from the given class name.

public Text
public XPath

Returns:

a new XPath instance
createXPath
(String
is the XPath expression to create
xpathExpression
)

createXPath parses an XPath expression and creates a new XPath XPath instance.

public XPath

Returns:

a new XPath instance
createXPath
(String
is the XPath expression to create
xpathExpression
,
VariableContext
is the variable context to use when evaluating the XPath
variableContext
)

createXPath parses an XPath expression and creates a new XPath XPath instance.

public NodeFilter

Returns:

a new NodeFilter instance
createXPathFilter
(String
is the XPath filter expression to create
xpathFilterExpression
,
VariableContext
is the variable context to use when evaluating the XPath
variableContext
)

createXPathFilter parses a NodeFilter from the given XPath filter expression.

public NodeFilter

Returns:

a new NodeFilter instance
createXPathFilter
(String
is the XPath filter expression to create
xpathFilterExpression
)

createXPathFilter parses a NodeFilter from the given XPath filter expression.

public static synchronized DocumentFactory

Returns:

the default singleon instance
getInstance
()

Access to singleton implementation of DocumentFactory which is used if no DocumentFactory is specified when building using the standard builders.

public List<QName>

Returns:

DOCUMENT ME!
getQNames
()

Returns a list of all the QName instances currently used by this document factory

public Map<String, String>

Returns:

the Map of namespace URIs that will be used by by XPath expressions to resolve namespace prefixes into namespace URIs. The map is keyed by namespace prefix and the value is the namespace URI. This value could well be null to indicate no namespace URIs are being mapped.
getXPathNamespaceURIs
()

DOCUMENT ME!

protected void
init()

protected QName

Returns:

the cached QName instance if there is one or adds the given qname to the cache if not
intern
(QName
DOCUMENT ME!
qname
)

DOCUMENT ME!

private void
public void
setXPathNamespaceURIs(Map<String, String>
DOCUMENT ME!
namespaceURIs
)

Sets the namespace URIs to be used by XPath expressions created by this factory or by nodes associated with this factory.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
protected transient QNameCache cache
singletonback to summary
private static SingletonStrategy<DocumentFactory> singleton
xpathNamespaceURIsback to summary
private Map<String, String> xpathNamespaceURIs

Default namespace prefix → URI mappings for XPath expressions to use

Constructor Detail

DocumentFactoryback to summary
public DocumentFactory()

Method Detail

createAttributeback to summary
public Attribute createAttribute(Element owner, QName qname, String value)
createAttributeback to summary
public Attribute createAttribute(Element owner, String name, String value)
createCDATAback to summary
public CDATA createCDATA(String text)
createCommentback to summary
public Comment createComment(String text)
createDocTypeback to summary
public DocumentType createDocType(String name, String publicId, String systemId)
createDocumentback to summary
public Document createDocument()
createDocumentback to summary
public Document createDocument(String encoding)

DOCUMENT ME!

Parameters
encoding:String

DOCUMENT ME!

Returns:Document

DOCUMENT ME!

Since
1.5
createDocumentback to summary
public Document createDocument(Element rootElement)
createElementback to summary
public Element createElement(QName qname)
createElementback to summary
public Element createElement(String name)
createElementback to summary
public Element createElement(String qualifiedName, String namespaceURI)
createEntityback to summary
public Entity createEntity(String name, String text)
createNamespaceback to summary
public Namespace createNamespace(String prefix, String uri)
createPatternback to summary
public Pattern createPattern(String xpathPattern)

createPattern parses the given XPath expression to create an XSLT style Patterninstance which can then be used in an XSLT processing model.

Parameters
xpathPattern:String

is the XPath pattern expression to create

Returns:Pattern

a new Pattern instance

createProcessingInstructionback to summary
public ProcessingInstruction createProcessingInstruction(String target, String data)
createProcessingInstructionback to summary
public ProcessingInstruction createProcessingInstruction(String target, Map<String, String> data)
createQNameback to summary
public QName createQName(String localName, Namespace namespace)
createQNameback to summary
public QName createQName(String localName)
createQNameback to summary
public QName createQName(String name, String prefix, String uri)
createQNameback to summary
public QName createQName(String qualifiedName, String uri)
createQNameCacheback to summary
protected QNameCache createQNameCache()

Factory method to create the QNameCache. This method should be overloaded if you wish to use your own derivation of QName.

Returns:QNameCache

DOCUMENT ME!

createSingletonback to summary
private static SingletonStrategy<DocumentFactory> createSingleton()
createSingletonback to summary
protected static DocumentFactory createSingleton(String className)

createSingleton creates the singleton instance from the given class name.

Parameters
className:String

is the name of the DocumentFactory class to use

Returns:DocumentFactory

a new singleton instance.

createTextback to summary
public Text createText(String text)
createXPathback to summary
public XPath createXPath(String xpathExpression) throws InvalidXPathException

createXPath parses an XPath expression and creates a new XPath XPath instance.

Parameters
xpathExpression:String

is the XPath expression to create

Returns:XPath

a new XPath instance

Exceptions
InvalidXPathException:
if the XPath expression is invalid
createXPathback to summary
public XPath createXPath(String xpathExpression, VariableContext variableContext)

createXPath parses an XPath expression and creates a new XPath XPath instance.

Parameters
xpathExpression:String

is the XPath expression to create

variableContext:VariableContext

is the variable context to use when evaluating the XPath

Returns:XPath

a new XPath instance

createXPathFilterback to summary
public NodeFilter createXPathFilter(String xpathFilterExpression, VariableContext variableContext)

createXPathFilter parses a NodeFilter from the given XPath filter expression. XPath filter expressions occur within XPath expressions such as self::node()[ filterExpression ]

Parameters
xpathFilterExpression:String

is the XPath filter expression to create

variableContext:VariableContext

is the variable context to use when evaluating the XPath

Returns:NodeFilter

a new NodeFilter instance

createXPathFilterback to summary
public NodeFilter createXPathFilter(String xpathFilterExpression)

createXPathFilter parses a NodeFilter from the given XPath filter expression. XPath filter expressions occur within XPath expressions such as self::node()[ filterExpression ]

Parameters
xpathFilterExpression:String

is the XPath filter expression to create

Returns:NodeFilter

a new NodeFilter instance

getInstanceback to summary
public static synchronized DocumentFactory getInstance()

Access to singleton implementation of DocumentFactory which is used if no DocumentFactory is specified when building using the standard builders.

Returns:DocumentFactory

the default singleon instance

getQNamesback to summary
public List<QName> getQNames()

Returns a list of all the QName instances currently used by this document factory

Returns:List<QName>

DOCUMENT ME!

getXPathNamespaceURIsback to summary
public Map<String, String> getXPathNamespaceURIs()

DOCUMENT ME!

Returns:Map<String, String>

the Map of namespace URIs that will be used by by XPath expressions to resolve namespace prefixes into namespace URIs. The map is keyed by namespace prefix and the value is the namespace URI. This value could well be null to indicate no namespace URIs are being mapped.

initback to summary
protected void init()
internback to summary
protected QName intern(QName qname)

DOCUMENT ME!

Parameters
qname:QName

DOCUMENT ME!

Returns:QName

the cached QName instance if there is one or adds the given qname to the cache if not

readObjectback to summary
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
setXPathNamespaceURIsback to summary
public void setXPathNamespaceURIs(Map<String, String> namespaceURIs)

Sets the namespace URIs to be used by XPath expressions created by this factory or by nodes associated with this factory. The keys are namespace prefixes and the values are namespace URIs.

Parameters
namespaceURIs:Map<String, String>

DOCUMENT ME!