Class DefaultDocument
java.lang.Object
org.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
org.dom4j.tree.AbstractDocument
org.dom4j.tree.DefaultDocument
- All Implemented Interfaces:
Serializable, Cloneable, Branch, Document, Node
- Direct Known Subclasses:
DOMDocument
DefaultDocument is the default DOM4J default implementation of
an XML document.
- Version:
- $Revision: 1.34 $
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionStore the contents of the document as a lazily createdListprivate DocumentTypeThe document type for this documentprivate DocumentFactoryThe document factory used by defaultprivate EntityResolverThe resolver of URIsprivate StringThe name of the documentprivate ElementThe root element of this documentFields inherited from class AbstractDocument
encodingFields inherited from class AbstractBranch
DEFAULT_CONTENT_LIST_SIZEFields inherited from class AbstractNode
NODE_TYPE_NAMESFields inherited from interface Node
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE -
Constructor Summary
ConstructorsConstructorDescriptionDefaultDocument(String name) DefaultDocument(String name, Element rootElement, DocumentType docType) DefaultDocument(DocumentType docType) DefaultDocument(Element rootElement) DefaultDocument(Element rootElement, DocumentType docType) -
Method Summary
Modifier and TypeMethodDescriptionaddDocType(String docTypeName, String publicId, String systemId) Adds a DOCTYPE declaration to this documentprotected voidprotected voidvoidClears the content for this branch, removing anyNodeinstances this branch may contain.clone()clonewill return a deep clone or if this node is read-only then clone will return the same instance.DOCUMENT ME!DOCUMENT ME!protected DocumentFactoryDOCUMENT ME!getName()getNamereturns the name of this node.Returns the rootElementfor this document.Return the encoding of this document, as part of the XML declaration This isnullwhen unspecified or when it is not known (such as when the Document was created in memory) or when the implementation does not support this operation.processingInstruction(String target) DOCUMENT ME!Returns a list of all the processing instructions in this branch.processingInstructions(String target) Returns a list of the processing instructions for the given target.protected booleanremoveNode(Node node) booleanremoveProcessingInstruction(String target) Removes the processing instruction for the given target if it existsprotected voidrootElementAdded(Element element) Called to set the root element variablevoidsetContent(List<Node> content) Sets the contents of this branch as aListofNodeinstances.voidsetDocType(DocumentType docType) Sets the DocumentType propertyvoidsetDocumentFactory(DocumentFactory documentFactory) voidsetEntityResolver(EntityResolver entityResolver) Sets the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documentsvoidSets the text data of this node or this method will throw anUnsupportedOperationExceptionif it is read-only.Methods inherited from class AbstractDocument
accept, add, addComment, addElement, addElement, addElement, addProcessingInstruction, addProcessingInstruction, asXML, asXPathResult, checkAddElementAllowed, childAdded, childRemoved, getDocument, getNodeType, getPath, getStringValue, getUniquePath, normalize, remove, setRootElement, setXMLEncoding, toString, writeMethods inherited from class AbstractBranch
add, add, add, addElement, appendContent, content, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getText, getTextTrim, hasContent, indexOf, invalidNodeTypeAddException, isReadOnly, node, nodeCount, nodeIterator, remove, remove, remove, setProcessingInstructionsMethods inherited from class AbstractNode
createPattern, createXPath, createXPathFilter, createXPathResult, detach, getNodeTypeName, getParent, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, setText, supportsParent, valueOfMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Branch
add, add, add, appendContent, content, elementByID, indexOf, node, nodeCount, nodeIterator, remove, remove, remove, setProcessingInstructionsMethods inherited from interface Node
createXPath, detach, getNodeTypeName, getParent, getPath, getText, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, setText, supportsParent, valueOf
-
Field Details
-
name
The name of the document -
rootElement
The root element of this document -
-
docType
The document type for this document -
documentFactory
The document factory used by default -
entityResolver
The resolver of URIs
-
-
Constructor Details
-
DefaultDocument
public DefaultDocument() -
DefaultDocument
-
DefaultDocument
-
DefaultDocument
-
DefaultDocument
-
DefaultDocument
-
-
Method Details
-
getName
Description copied from interface:NodegetNamereturns the name of this node. This is the XML local name of the element, attribute, entity or processing instruction. For CDATA and Text nodes this method will return null.- Specified by:
getNamein interfaceNode- Overrides:
getNamein classAbstractNode- Returns:
- the XML name of this node
-
setName
Description copied from interface:NodeSets the text data of this node or this method will throw an
UnsupportedOperationExceptionif it is read-only.- Specified by:
setNamein interfaceNode- Overrides:
setNamein classAbstractNode- Parameters:
name- is the new name of this node
-
getRootElement
-
getDocType
-
setDocType
Description copied from interface:DocumentSets the DocumentType property- Parameters:
docType- DOCUMENT ME!
-
addDocType
Description copied from interface:DocumentAdds a DOCTYPE declaration to this document- Parameters:
docTypeName- is the name of the root elementpublicId- is the PUBLIC URIsystemId- is the SYSTEM URI- Returns:
- this
Documentinstance.
-
getXMLEncoding
Description copied from interface:DocumentReturn the encoding of this document, as part of the XML declaration This isnullwhen unspecified or when it is not known (such as when the Document was created in memory) or when the implementation does not support this operation. The way this encoding is retrieved also depends on the way the XML source is parsed. For instance, if the SAXReader is used and if the underlying XMLReader implementation support theorg.xml.sax.ext.Locator2interface, the result returned by this method is specified by thegetEncoding()method of that interface.- Specified by:
getXMLEncodingin interfaceDocument- Overrides:
getXMLEncodingin classAbstractDocument- Returns:
- The encoding of this document, as stated in the XML declaration,
or
nullif unknown.
-
getEntityResolver
Description copied from interface:DocumentDOCUMENT ME!- Returns:
- the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents
-
setEntityResolver
Description copied from interface:DocumentSets the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents- Parameters:
entityResolver- DOCUMENT ME!
-
clone
Description copied from interface:Nodeclonewill return a deep clone or if this node is read-only then clone will return the same instance.- Specified by:
clonein interfaceNode- Overrides:
clonein classAbstractNode- Returns:
- a deep clone of myself or myself if I am read only.
-
processingInstructions
Description copied from interface:BranchReturns a list of all the processing instructions in this branch. The list is backed by this branch so that changes to the list will be reflected in the branch but the reverse is not the case.- Returns:
- a backed list of the processing instructions
-
processingInstructions
Description copied from interface:BranchReturns a list of the processing instructions for the given target. The list is backed by this branch so that changes to the list will be reflected in the branch but the reverse is not the case.- Parameters:
target- DOCUMENT ME!- Returns:
- a backed list of the processing instructions
-
processingInstruction
Description copied from interface:BranchDOCUMENT ME!- Parameters:
target- DOCUMENT ME!- Returns:
- the processing instruction for the given target
-
removeProcessingInstruction
-
setContent
-
clearContent
public void clearContent()Description copied from interface:BranchClears the content for this branch, removing anyNodeinstances this branch may contain. -
setDocumentFactory
-
contentList
Description copied from class:AbstractBranchDOCUMENT ME!- Specified by:
contentListin classAbstractBranch- Returns:
- the internal List used to manage the content
-
addNode
- Specified by:
addNodein classAbstractBranch
-
addNode
- Specified by:
addNodein classAbstractBranch
-
removeNode
- Specified by:
removeNodein classAbstractBranch
-
rootElementAdded
Description copied from class:AbstractDocumentCalled to set the root element variable- Specified by:
rootElementAddedin classAbstractDocument- Parameters:
element- DOCUMENT ME!
-
getDocumentFactory
- Overrides:
getDocumentFactoryin classAbstractNode
-