Top Description Fields Constructors Methods
org.dom4j.tree

public Class DefaultDocument

extends AbstractDocument
Class Inheritance
Known Direct Subclasses
org.dom4j.dom.DOMDocument
Imports
org.dom4j.*, org.xml.sax.EntityResolver, java.util.Iterator, .List

DefaultDocument is the default DOM4J default implementation of an XML document.

Author
James Strachan
Version
$Revision: 1.34 $

Field Summary

Modifier and TypeField and Description
private List<Node>
content

Store the contents of the document as a lazily created List

private DocumentType
docType

The document type for this document

private DocumentFactory
documentFactory

The document factory used by default

private transient EntityResolver
entityResolver

The resolver of URIs

private String
name

The name of the document

private Element
rootElement

The root element of this document

Inherited from org.dom4j.tree.AbstractDocument:
encoding

Constructor Summary

AccessConstructor and Description
public
public
public
DefaultDocument(Element rootElement)

public
public
DefaultDocument(Element rootElement, DocumentType docType)

public
DefaultDocument(String name, Element rootElement, DocumentType docType)

Method Summary

Modifier and TypeMethod and Description
public Document
addDocType(String
is the name of the root element
docTypeName
,
String
is the PUBLIC URI
publicId
,
String
is the SYSTEM URI
systemId
)

Implements org.dom4j.Document.addDocType.

Adds a DOCTYPE declaration to this document
protected void
protected void
addNode(int index, Node node)

Implements abstract org.dom4j.tree.AbstractBranch.addNode.

public void
clearContent()

Implements org.dom4j.Branch.clearContent.

Clears the content for this branch, removing any Node instances this branch may contain.
public Object
clone()

Overrides org.dom4j.tree.AbstractNode.clone.

Implements org.dom4j.Node.clone.

clone will return a deep clone or if this node is read-only then clone will return the same instance.

protected List<Node>
contentList()

Implements abstract org.dom4j.tree.AbstractBranch.contentList.

DOCUMENT ME!
public DocumentType
getDocType()

Implements org.dom4j.Document.getDocType.

DOCUMENT ME!
protected DocumentFactory
public EntityResolver
public String
getName()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

getName returns the name of this node.

public Element
getRootElement()

Implements org.dom4j.Document.getRootElement.

Returns the root Elementfor this document.
public String
getXMLEncoding()

Overrides org.dom4j.tree.AbstractDocument.getXMLEncoding.

Implements org.dom4j.Document.getXMLEncoding.

Return the encoding of this document, as part of the XML declaration This is null when 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.
public ProcessingInstruction
processingInstruction(String
DOCUMENT ME!
target
)

Implements org.dom4j.Branch.processingInstruction.

DOCUMENT ME!
public List<ProcessingInstruction>
processingInstructions()

Implements org.dom4j.Branch.processingInstructions.

Returns a list of all the processing instructions in this branch.
public List<ProcessingInstruction>
processingInstructions(String
DOCUMENT ME!
target
)

Implements org.dom4j.Branch.processingInstructions.

Returns a list of the processing instructions for the given target.
protected boolean
public boolean
removeProcessingInstruction(String
DOCUMENT ME!
target
)

Implements org.dom4j.Branch.removeProcessingInstruction.

Removes the processing instruction for the given target if it exists
protected void
rootElementAdded(Element
DOCUMENT ME!
element
)

Implements abstract org.dom4j.tree.AbstractDocument.rootElementAdded.

Called to set the root element variable
public void
setContent(List<Node>
is the list of nodes to use as the content for this branch.
content
)

Implements org.dom4j.Branch.setContent.

Sets the contents of this branch as a List of Node instances.
public void
setDocType(DocumentType
DOCUMENT ME!
docType
)

Implements org.dom4j.Document.setDocType.

Sets the DocumentType property
public void
public void
setEntityResolver(EntityResolver
DOCUMENT ME!
entityResolver
)

Implements org.dom4j.Document.setEntityResolver.

Sets the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents
public void
setName(String
is the new name of this node
name
)

Overrides org.dom4j.tree.AbstractNode.setName.

Implements org.dom4j.Node.setName.

Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only.

Inherited from org.dom4j.tree.AbstractDocument:
acceptaddaddCommentaddElementaddElementaddElementaddProcessingInstructionaddProcessingInstructionasXMLasXPathResultcheckAddElementAllowedchildAddedchildRemovedgetDocumentgetNodeTypegetPathgetStringValuegetUniquePathnormalizeremovesetRootElementsetXMLEncodingtoStringwrite

Field Detail

contentback to summary
private List<Node> content

Store the contents of the document as a lazily created List

docTypeback to summary
private DocumentType docType

The document type for this document

documentFactoryback to summary
private DocumentFactory documentFactory

The document factory used by default

entityResolverback to summary
private transient EntityResolver entityResolver

The resolver of URIs

nameback to summary
private String name

The name of the document

rootElementback to summary
private Element rootElement

The root element of this document

Constructor Detail

DefaultDocumentback to summary
public DefaultDocument()
DefaultDocumentback to summary
public DefaultDocument(String name)
DefaultDocumentback to summary
public DefaultDocument(Element rootElement)
DefaultDocumentback to summary
public DefaultDocument(DocumentType docType)
DefaultDocumentback to summary
public DefaultDocument(Element rootElement, DocumentType docType)
DefaultDocumentback to summary
public DefaultDocument(String name, Element rootElement, DocumentType docType)

Method Detail

addDocTypeback to summary
public Document addDocType(String docTypeName, String publicId, String systemId)

Implements org.dom4j.Document.addDocType.

Doc from org.dom4j.Document.addDocType.

Adds a DOCTYPE declaration to this document

Parameters
docTypeName:String

is the name of the root element

publicId:String

is the PUBLIC URI

systemId:String

is the SYSTEM URI

Returns:Document

this Document instance.

addNodeback to summary
protected void addNode(Node node)

Implements abstract org.dom4j.tree.AbstractBranch.addNode.

addNodeback to summary
protected void addNode(int index, Node node)

Implements abstract org.dom4j.tree.AbstractBranch.addNode.

clearContentback to summary
public void clearContent()

Implements org.dom4j.Branch.clearContent.

Doc from org.dom4j.Branch.clearContent.

Clears the content for this branch, removing any Node instances this branch may contain.

cloneback to summary
public Object clone()

Overrides org.dom4j.tree.AbstractNode.clone.

Implements org.dom4j.Node.clone.

Doc from org.dom4j.Node.clone.

clone will return a deep clone or if this node is read-only then clone will return the same instance.

Returns:Object

a deep clone of myself or myself if I am read only.

contentListback to summary
protected List<Node> contentList()

Implements abstract org.dom4j.tree.AbstractBranch.contentList.

Doc from org.dom4j.tree.AbstractBranch.contentList.

DOCUMENT ME!

Returns:List<Node>

the internal List used to manage the content

getDocTypeback to summary
public DocumentType getDocType()

Implements org.dom4j.Document.getDocType.

Doc from org.dom4j.Document.getDocType.

DOCUMENT ME!

Returns:DocumentType

the DocumentType property

getDocumentFactoryback to summary
protected DocumentFactory getDocumentFactory()

Overrides org.dom4j.tree.AbstractNode.getDocumentFactory.

getEntityResolverback to summary
public EntityResolver getEntityResolver()

Implements org.dom4j.Document.getEntityResolver.

Doc from org.dom4j.Document.getEntityResolver.

DOCUMENT ME!

Returns:EntityResolver

the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents

getNameback to summary
public String getName()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

Doc from org.dom4j.Node.getName.

getName returns 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.

Returns:String

the XML name of this node

getRootElementback to summary
public Element getRootElement()

Implements org.dom4j.Document.getRootElement.

Doc from org.dom4j.Document.getRootElement.

Returns the root Elementfor this document.

Returns:Element

the root element for this document

getXMLEncodingback to summary
public String getXMLEncoding()

Overrides org.dom4j.tree.AbstractDocument.getXMLEncoding.

Implements org.dom4j.Document.getXMLEncoding.

Doc from org.dom4j.Document.getXMLEncoding.

Return the encoding of this document, as part of the XML declaration This is null when 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 the org.xml.sax.ext.Locator2 interface, the result returned by this method is specified by the getEncoding() method of that interface.

Returns:String

The encoding of this document, as stated in the XML declaration, or null if unknown.

processingInstructionback to summary
public ProcessingInstruction processingInstruction(String target)

Implements org.dom4j.Branch.processingInstruction.

Doc from org.dom4j.Branch.processingInstruction.

DOCUMENT ME!

Parameters
target:String

DOCUMENT ME!

Returns:ProcessingInstruction

the processing instruction for the given target

processingInstructionsback to summary
public List<ProcessingInstruction> processingInstructions()

Implements org.dom4j.Branch.processingInstructions.

Doc from org.dom4j.Branch.processingInstructions.

Returns 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:List<ProcessingInstruction>

a backed list of the processing instructions

processingInstructionsback to summary
public List<ProcessingInstruction> processingInstructions(String target)

Implements org.dom4j.Branch.processingInstructions.

Doc from org.dom4j.Branch.processingInstructions.

Returns 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:String

DOCUMENT ME!

Returns:List<ProcessingInstruction>

a backed list of the processing instructions

removeNodeback to summary
protected boolean removeNode(Node node)

Implements abstract org.dom4j.tree.AbstractBranch.removeNode.

removeProcessingInstructionback to summary
public boolean removeProcessingInstruction(String target)

Implements org.dom4j.Branch.removeProcessingInstruction.

Doc from org.dom4j.Branch.removeProcessingInstruction.

Removes the processing instruction for the given target if it exists

Parameters
target:String

DOCUMENT ME!

Returns:boolean

true if a processing instruction was removed else false

rootElementAddedback to summary
protected void rootElementAdded(Element element)

Implements abstract org.dom4j.tree.AbstractDocument.rootElementAdded.

Doc from org.dom4j.tree.AbstractDocument.rootElementAdded.

Called to set the root element variable

Parameters
element:Element

DOCUMENT ME!

setContentback to summary
public void setContent(List<Node> content)

Implements org.dom4j.Branch.setContent.

Doc from org.dom4j.Branch.setContent.

Sets the contents of this branch as a List of Node instances.

Parameters
content:List<Node>

is the list of nodes to use as the content for this branch.

setDocTypeback to summary
public void setDocType(DocumentType docType)

Implements org.dom4j.Document.setDocType.

Doc from org.dom4j.Document.setDocType.

Sets the DocumentType property

Parameters
docType:DocumentType

DOCUMENT ME!

setDocumentFactoryback to summary
public void setDocumentFactory(DocumentFactory documentFactory)
setEntityResolverback to summary
public void setEntityResolver(EntityResolver entityResolver)

Implements org.dom4j.Document.setEntityResolver.

Doc from org.dom4j.Document.setEntityResolver.

Sets the EntityResolver used to find resolve URIs such as for DTDs, or XML Schema documents

Parameters
entityResolver:EntityResolver

DOCUMENT ME!

setNameback to summary
public void setName(String name)

Overrides org.dom4j.tree.AbstractNode.setName.

Implements org.dom4j.Node.setName.

Doc from org.dom4j.Node.setName.

Sets the text data of this node or this method will throw an UnsupportedOperationException if it is read-only.

Parameters
name:String

is the new name of this node