Class DocumentFactory
- java.lang.Object
-
- org.dom4j.DocumentFactory
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
BeanDocumentFactory,DatatypeDocumentFactory,DatatypeElementFactory,DOMDocumentFactory,IndexedDocumentFactory,NonLazyDocumentFactory,UserDataDocumentFactory
public class DocumentFactory extends java.lang.Object implements java.io.SerializableDocumentFactoryis 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.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected QNameCachecache
-
Constructor Summary
Constructors Constructor Description DocumentFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributecreateAttribute(Element owner, java.lang.String name, java.lang.String value)AttributecreateAttribute(Element owner, QName qname, java.lang.String value)CDATAcreateCDATA(java.lang.String text)CommentcreateComment(java.lang.String text)DocumentTypecreateDocType(java.lang.String name, java.lang.String publicId, java.lang.String systemId)DocumentcreateDocument()DocumentcreateDocument(java.lang.String encoding)DOCUMENT ME!DocumentcreateDocument(Element rootElement)ElementcreateElement(java.lang.String name)ElementcreateElement(java.lang.String qualifiedName, java.lang.String namespaceURI)ElementcreateElement(QName qname)EntitycreateEntity(java.lang.String name, java.lang.String text)NamespacecreateNamespace(java.lang.String prefix, java.lang.String uri)PatterncreatePattern(java.lang.String xpathPattern)createPatternparses the given XPath expression to create an XSLT stylePatterninstance which can then be used in an XSLT processing model.ProcessingInstructioncreateProcessingInstruction(java.lang.String target, java.lang.String data)ProcessingInstructioncreateProcessingInstruction(java.lang.String target, java.util.Map<java.lang.String,java.lang.String> data)QNamecreateQName(java.lang.String localName)QNamecreateQName(java.lang.String qualifiedName, java.lang.String uri)QNamecreateQName(java.lang.String name, java.lang.String prefix, java.lang.String uri)QNamecreateQName(java.lang.String localName, Namespace namespace)protected QNameCachecreateQNameCache()Factory method to create the QNameCache.protected static DocumentFactorycreateSingleton(java.lang.String className)createSingletoncreates the singleton instance from the given class name.TextcreateText(java.lang.String text)XPathcreateXPath(java.lang.String xpathExpression)createXPathparses an XPath expression and creates a new XPathXPathinstance.XPathcreateXPath(java.lang.String xpathExpression, org.jaxen.VariableContext variableContext)createXPathparses an XPath expression and creates a new XPathXPathinstance.NodeFiltercreateXPathFilter(java.lang.String xpathFilterExpression)createXPathFilterparses a NodeFilter from the given XPath filter expression.NodeFiltercreateXPathFilter(java.lang.String xpathFilterExpression, org.jaxen.VariableContext variableContext)createXPathFilterparses a NodeFilter from the given XPath filter expression.static DocumentFactorygetInstance()Access to singleton implementation of DocumentFactory which is used if no DocumentFactory is specified when building using the standard builders.java.util.List<QName>getQNames()Returns a list of all the QName instances currently used by this document factoryjava.util.Map<java.lang.String,java.lang.String>getXPathNamespaceURIs()DOCUMENT ME!protected voidinit()protected QNameintern(QName qname)DOCUMENT ME!voidsetXPathNamespaceURIs(java.util.Map<java.lang.String,java.lang.String> namespaceURIs)Sets the namespace URIs to be used by XPath expressions created by this factory or by nodes associated with this factory.
-
-
-
Field Detail
-
cache
protected transient QNameCache cache
-
-
Method Detail
-
getInstance
public static DocumentFactory getInstance()
Access to singleton implementation of DocumentFactory which is used if no DocumentFactory is specified when building using the standard builders.- Returns:
- the default singleon instance
-
createDocument
public Document createDocument()
-
createDocument
public Document createDocument(java.lang.String encoding)
DOCUMENT ME!- Parameters:
encoding- DOCUMENT ME!- Returns:
- DOCUMENT ME!
- Since:
- 1.5
-
createDocType
public DocumentType createDocType(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
-
createElement
public Element createElement(java.lang.String name)
-
createElement
public Element createElement(java.lang.String qualifiedName, java.lang.String namespaceURI)
-
createAttribute
public Attribute createAttribute(Element owner, QName qname, java.lang.String value)
-
createAttribute
public Attribute createAttribute(Element owner, java.lang.String name, java.lang.String value)
-
createCDATA
public CDATA createCDATA(java.lang.String text)
-
createComment
public Comment createComment(java.lang.String text)
-
createText
public Text createText(java.lang.String text)
-
createEntity
public Entity createEntity(java.lang.String name, java.lang.String text)
-
createNamespace
public Namespace createNamespace(java.lang.String prefix, java.lang.String uri)
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data)
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(java.lang.String target, java.util.Map<java.lang.String,java.lang.String> data)
-
createQName
public QName createQName(java.lang.String localName)
-
createQName
public QName createQName(java.lang.String name, java.lang.String prefix, java.lang.String uri)
-
createQName
public QName createQName(java.lang.String qualifiedName, java.lang.String uri)
-
createXPath
public XPath createXPath(java.lang.String xpathExpression) throws InvalidXPathException
createXPathparses an XPath expression and creates a new XPathXPathinstance.- Parameters:
xpathExpression- is the XPath expression to create- Returns:
- a new
XPathinstance - Throws:
InvalidXPathException- if the XPath expression is invalid
-
createXPath
public XPath createXPath(java.lang.String xpathExpression, org.jaxen.VariableContext variableContext)
createXPathparses an XPath expression and creates a new XPathXPathinstance.- Parameters:
xpathExpression- is the XPath expression to createvariableContext- is the variable context to use when evaluating the XPath- Returns:
- a new
XPathinstance
-
createXPathFilter
public NodeFilter createXPathFilter(java.lang.String xpathFilterExpression, org.jaxen.VariableContext variableContext)
createXPathFilterparses a NodeFilter from the given XPath filter expression. XPath filter expressions occur within XPath expressions such asself::node()[ filterExpression ]- Parameters:
xpathFilterExpression- is the XPath filter expression to createvariableContext- is the variable context to use when evaluating the XPath- Returns:
- a new
NodeFilterinstance
-
createXPathFilter
public NodeFilter createXPathFilter(java.lang.String xpathFilterExpression)
createXPathFilterparses a NodeFilter from the given XPath filter expression. XPath filter expressions occur within XPath expressions such asself::node()[ filterExpression ]- Parameters:
xpathFilterExpression- is the XPath filter expression to create- Returns:
- a new
NodeFilterinstance
-
createPattern
public Pattern createPattern(java.lang.String xpathPattern)
createPatternparses the given XPath expression to create an XSLT stylePatterninstance which can then be used in an XSLT processing model.- Parameters:
xpathPattern- is the XPath pattern expression to create- Returns:
- a new
Patterninstance
-
getQNames
public java.util.List<QName> getQNames()
Returns a list of all the QName instances currently used by this document factory- Returns:
- DOCUMENT ME!
-
getXPathNamespaceURIs
public java.util.Map<java.lang.String,java.lang.String> getXPathNamespaceURIs()
DOCUMENT ME!- 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.
-
setXPathNamespaceURIs
public void setXPathNamespaceURIs(java.util.Map<java.lang.String,java.lang.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- DOCUMENT ME!
-
createSingleton
protected static DocumentFactory createSingleton(java.lang.String className)
createSingletoncreates the singleton instance from the given class name.- Parameters:
className- is the name of the DocumentFactory class to use- Returns:
- a new singleton instance.
-
intern
protected QName intern(QName qname)
DOCUMENT ME!- Parameters:
qname- DOCUMENT ME!- Returns:
- the cached QName instance if there is one or adds the given qname to the cache if not
-
createQNameCache
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:
- DOCUMENT ME!
-
init
protected void init()
-
-