Top Description Fields Constructors Methods
org.dom4j.tree

public abstract Class AbstractElement

extends AbstractBranch
implements Element
Class Inheritance
All Implemented Interfaces
org.dom4j.Element, org.dom4j.Branch, org.dom4j.Node, java.lang.Cloneable
Known Direct Subclasses
org.dom4j.tree.BaseElement, org.dom4j.tree.DefaultElement
Annotations
@SuppressWarnings:unused
Imports
org.dom4j.*, org.dom4j.io.OutputFormat, .XMLWriter, org.xml.sax.Attributes, java.io.IOException, .StringWriter, .Writer, java.util.*

AbstractElement is an abstract base class for tree implementors to use for implementation inheritence.

Author
James Strachan
Version
$Revision: 1.80 $

Field Summary

Modifier and TypeField and Description
private static final DocumentFactory
DOCUMENT_FACTORY

Hides org.dom4j.tree.AbstractNode.DOCUMENT_FACTORY.

The DocumentFactory instance used by default
protected static final boolean
protected static final boolean
Inherited from org.dom4j.tree.AbstractBranch:
DEFAULT_CONTENT_LIST_SIZE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
accept(Visitor
Visitor is the visitor.
visitor
)

Implements org.dom4j.Node.accept.

accept method is the Visitor Pattern method.

public void
add(Attribute
is the attribute to be added
attribute
)

Implements org.dom4j.Element.add.

Adds the given Attribute to this element.
public void
add(Node
is the given node to add
node
)

Overrides org.dom4j.tree.AbstractBranch.add.

Implements org.dom4j.Branch.add.

Adds the given Node or throws IllegalAddException if the given node is not of a valid type.
public void
add(CDATA
is the CDATA to be added
cdata
)

Implements org.dom4j.Element.add.

Adds the given CDATA to this element.
public void
add(Comment
is the comment to be added
comment
)

Overrides org.dom4j.tree.AbstractBranch.add.

Implements org.dom4j.Branch.add.

Adds the given Comment to this branch.
public void
add(Element
is the element to be added
element
)

Overrides org.dom4j.tree.AbstractBranch.add.

Implements org.dom4j.Branch.add.

Adds the given Element to this branch.
public void
add(Entity
is the entity to be added
entity
)

Implements org.dom4j.Element.add.

Adds the given Entity to this element.
public void
add(Namespace
is the namespace to be added
namespace
)

Implements org.dom4j.Element.add.

Adds the given Namespace to this element.
public void
add(ProcessingInstruction
is the processing instruction to be added
pi
)

Overrides org.dom4j.tree.AbstractBranch.add.

Implements org.dom4j.Branch.add.

Adds the given ProcessingInstruction to this branch.
public void
add(Text
is the text to be added
text
)

Implements org.dom4j.Element.add.

Adds the given Text to this element.
public Element
addAttribute(String
is the name of the attribute whose value is to be added or updated
name
,
String
is the attribute's value
value
)

Implements org.dom4j.Element.addAttribute.

Adds the attribute value of the given local name.
public Element
addAttribute(QName
is the fully qualified name of the attribute whose value is to be added or updated
qName
,
String
is the attribute's value
value
)

Implements org.dom4j.Element.addAttribute.

Adds the attribute value of the given fully qualified name.
public Element
addCDATA(String
is the text for the CDATA node.
cdata
)

Implements org.dom4j.Element.addCDATA.

Adds a new CDATA node with the given text to this element.
public Element
addComment(String
is the text for the Comment node.
comment
)

Implements org.dom4j.Element.addComment.

Adds a new Comment node with the given text to this element.
public Element
addElement(String
is the name for the Element node.
name
)

Overrides org.dom4j.tree.AbstractBranch.addElement.

Implements org.dom4j.Branch.addElement.

Adds a new Element node with the given name to this branch and returns a reference to the new node.
public Element
addEntity(String
is the name for the Entity node.
name
,
String
is the text for the Entity node.
text
)

Implements org.dom4j.Element.addEntity.

Adds a new Entity node with the given name and text to this element and returns a reference to the new node.
public List<Namespace>
additionalNamespaces()

Implements org.dom4j.Element.additionalNamespaces.

Returns any additional namespaces declarations for this element other than namespace returned via the getNamespace()method.
public List<Namespace>
additionalNamespaces(String defaultNamespaceURI)

public Element
addNamespace(String
is the prefix to use, which should not be null or blank
prefix
,
String
is the namespace URI
uri
)

Implements org.dom4j.Element.addNamespace.

Adds a namespace to this element for use by its child content
protected void
addNewNode(Node
DOCUMENT ME!
node
)

Like addNode() but does not require a parent check

protected void
addNewNode(int index, Node node)

protected void
protected void
addNode(int index, Node node)

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

public Element
addProcessingInstruction(String
is the target of the processing instruction
target
,
String
is the textual data (key/value pairs) of the processing instruction
data
)

Implements org.dom4j.Element.addProcessingInstruction.

Adds a processing instruction for the given target
public Element
addProcessingInstruction(String
is the target of the processing instruction
target
,
Map<String, String>
is a Map of the key / value pairs of the processing instruction
data
)

Implements org.dom4j.Element.addProcessingInstruction.

Adds a processing instruction for the given target
public Element
addText(String
is the text for the Text node.
text
)

Implements org.dom4j.Element.addText.

Adds a new Text node with the given text to this element.
public void
appendAttributes(Element
is the element whose attributes will be added to me.
element
)

Implements org.dom4j.Element.appendAttributes.

Appends the attributes of the given element to me.
public String
asXML()

Implements org.dom4j.Node.asXML.

asXML returns the textual XML representation of this node.

public Attribute
attribute(int
DOCUMENT ME!
index
)

Implements org.dom4j.Element.attribute.

Returns the attribute at the specified indexGets the
public Attribute
attribute(String
DOCUMENT ME!
name
)

Implements org.dom4j.Element.attribute.

Returns the attribute with the given name
public Attribute
attribute(QName
is the fully qualified name
qName
)

Implements org.dom4j.Element.attribute.

DOCUMENT ME!
public Attribute
attribute(String name, Namespace namespace)

public int
public Iterator<Attribute>
protected abstract List<Attribute>

Returns:

the internal List used to store attributes or creates one if one is not available
attributeList
()

DOCUMENT ME!

protected abstract List<Attribute>

Returns:

the internal List used to store attributes or creates one with the specified size if one is not available
attributeList
(int
DOCUMENT ME!
attributeCount
)

DOCUMENT ME!

public List<Attribute>
attributes()

Implements org.dom4j.Element.attributes.

Returns the Attributeinstances this element contains as a backed Listso that the attributes may be modified directly using the Listinterface.
public String
attributeValue(String
is the name of the attribute value to be returned
name
)

Implements org.dom4j.Element.attributeValue.

This returns the attribute value for the attribute with the given name and any namespace or null if there is no such attribute or the empty string if the attribute value is empty.
public String
attributeValue(QName
is the fully qualified name
qName
)

Implements org.dom4j.Element.attributeValue.

This returns the attribute value for the attribute with the given fully qualified name or null if there is no such attribute or the empty string if the attribute value is empty.
public String
attributeValue(String
is the name of the attribute value to be returned
name
,
String
is the default value to be returned if the attribute has no value defined.
defaultValue
)

Implements org.dom4j.Element.attributeValue.

This returns the attribute value for the attribute with the given name and any namespace or the default value if there is no such attribute value.
public String
attributeValue(QName
is the fully qualified name
qName
,
String
is the default value to be returned if the attribute has no value defined.
defaultValue
)

Implements org.dom4j.Element.attributeValue.

This returns the attribute value for the attribute with the given fully qualified name or the default value if there is no such attribute value.
protected void
childAdded(Node
DOCUMENT ME!
node
)

Implements abstract org.dom4j.tree.AbstractBranch.childAdded.

Called when a new child node is added to create any parent relationships
protected void
childRemoved(Node
DOCUMENT ME!
node
)

Implements abstract org.dom4j.tree.AbstractBranch.childRemoved.

Called when a child node has been removed to allow any parent relationships to be deleted or events to be fired.
protected List<Attribute>

Returns:

DOCUMENT ME!
createAttributeList
()

A Factory Method pattern which creates a List implementation used to store attributes

protected List<Attribute>

Returns:

DOCUMENT ME!
createAttributeList
(int
DOCUMENT ME!
size
)

A Factory Method pattern which creates a List implementation used to store attributes

public Element

Returns:

the clone of this element
createCopy
()

Implements org.dom4j.Element.createCopy.

This returns a deep clone of this element.

public Element
createCopy(String
DOCUMENT ME!
name
)

Implements org.dom4j.Element.createCopy.

Creates a deep copy of this element with the given local name The new element is detached from its parent, and getParent() on the clone will return null.
public Element
createCopy(QName
DOCUMENT ME!
qName
)

Implements org.dom4j.Element.createCopy.

Creates a deep copy of this element with the given fully qualified name.
protected Element
protected Element
protected <T> Iterator<T>
public List<Namespace>
declaredNamespaces()

Implements org.dom4j.Element.declaredNamespaces.

Returns all the namespaces declared by this element.
public Element
element(String
DOCUMENT ME!
name
)

Implements org.dom4j.Element.element.

Returns the first element for the given local name and any namespace.
public Element
element(QName
is the fully qualified name to search for
qName
)

Implements org.dom4j.Element.element.

Returns the first element for the given fully qualified name.
public Element
element(String name, Namespace namespace)

public Iterator<Element>
elementIterator()

Implements org.dom4j.Element.elementIterator.

Returns an iterator over all this elements child elements.
public Iterator<Element>
elementIterator(String
DOCUMENT ME!
name
)

Implements org.dom4j.Element.elementIterator.

Returns an iterator over the elements contained in this element which match the given local name and any namespace.
public Iterator<Element>
elementIterator(QName
is the fully qualified name to search for
qName
)

Implements org.dom4j.Element.elementIterator.

Returns an iterator over the elements contained in this element which match the given fully qualified name.
public Iterator<Element>
public List<Element>
elements()

Implements org.dom4j.Element.elements.

Returns the elements contained in this element.
public List<Element>
elements(String
DOCUMENT ME!
name
)

Implements org.dom4j.Element.elements.

Returns the elements contained in this element with the given local name and any namespace.
public List<Element>
elements(QName
is the fully qualified name to search for
qName
)

Implements org.dom4j.Element.elements.

Returns the elements contained in this element with the given fully qualified name.
public List<Element>
elements(String name, Namespace namespace)

public String
public String
public String
public String
public void
ensureAttributesCapacity(int
DOCUMENT ME!
minCapacity
)

Ensures that the list of attributes has the given size

public Object
getData()

Implements org.dom4j.Element.getData.

Accesses the data of this element which may implement data typing bindings such as XML Schema or Java Bean bindings or will return the same value as getText
protected DocumentFactory
public String
getName()

Overrides org.dom4j.tree.AbstractNode.getName.

Implements org.dom4j.Node.getName.

getName returns the name of this node.

public Namespace
getNamespace()

Implements org.dom4j.Element.getNamespace.

Returns the Namespace of this element if one exists otherwise Namespace.NO_NAMESPACE is returned.
public Namespace
getNamespaceForPrefix(String
DOCUMENT ME!
prefix
)

Implements org.dom4j.Element.getNamespaceForPrefix.

Returns the Namespace which is mapped to the given prefix or null if it could not be found.
public Namespace
getNamespaceForURI(String
DOCUMENT ME!
uri
)

Implements org.dom4j.Element.getNamespaceForURI.

Returns the Namespace which is mapped to the given URI or null if it could not be found.
public String
getNamespacePrefix()

Implements org.dom4j.Element.getNamespacePrefix.

Returns the namespace prefix of this element if one exists otherwise an empty String is returned.
public List<Namespace>
getNamespacesForURI(String
DOCUMENT ME!
uri
)

Implements org.dom4j.Element.getNamespacesForURI.

Returns the all namespaces which are mapped to the given URI or an empty list if no such namespaces could be found.
public String
getNamespaceURI()

Implements org.dom4j.Element.getNamespaceURI.

Returns the URI mapped to the namespace of this element if one exists otherwise an empty String is returned.
public short
getNodeType()

Overrides org.dom4j.tree.AbstractNode.getNodeType.

Implements org.dom4j.Node.getNodeType.

Returns the code according to the type of node.
public String
getPath(Element
is the parent context from which the relative path should start. If the context is null or the context is not an ancestor of this node then the path will be absolute and start from the document and so begin with the '/' character.
context
)

Implements org.dom4j.Node.getPath.

Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c.
public QName
getQName(String
DOCUMENT ME!
qualifiedName
)

Implements org.dom4j.Element.getQName.

Returns the QName for the given qualified name, using the namespace URI in scope for the given prefix of the qualified name or the default namespace if the qualified name has no prefix.
public String
getQualifiedName()

Implements org.dom4j.Element.getQualifiedName.

Returns the fully qualified name of this element.
public String
public String
getUniquePath(Element
is the parent context from which the path should start. If the context is null or the context is not an ancestor of this node then the path will start from the document and so begin with the '/' character.
context
)

Implements org.dom4j.Node.getUniquePath.

Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node.

public String

Returns:

DOCUMENT ME!
getXPathNameStep
()

Returns the XPath expression to match this Elements name which is getQualifiedName() if there is a namespace prefix defined or if no namespace is present then it is getName() or if a namespace is defined with no prefix then the expression is [name()='X'] where X = getName().

public Node
getXPathResult(int
DOCUMENT ME!
index
)

Implements org.dom4j.Element.getXPathResult.

Returns a node at the given index suitable for an XPath result set.
public boolean
hasMixedContent()

Implements org.dom4j.Element.hasMixedContent.

Returns true if this Element has mixed content.
public int
indexOf(Node
the content child node to find.
node
)

Overrides org.dom4j.tree.AbstractBranch.indexOf.

Implements org.dom4j.Branch.indexOf.

Returns the index of the given node if it is a child node of this branch or -1 if the given node is not a child node.
public boolean
public boolean
isTextOnly()

Implements org.dom4j.Element.isTextOnly.

Returns true if this Element has text only content.
public Node
node(int
the index of the node to return.
index
)

Overrides org.dom4j.tree.AbstractBranch.node.

Implements org.dom4j.Branch.node.

Returns the Node at the specified index position.
public int
nodeCount()

Overrides org.dom4j.tree.AbstractBranch.nodeCount.

Implements org.dom4j.Branch.nodeCount.

Returns the number of Node instances that this branch contains.
public Iterator<Node>
nodeIterator()

Overrides org.dom4j.tree.AbstractBranch.nodeIterator.

Implements org.dom4j.Branch.nodeIterator.

Returns an iterator through the content nodes of this branch
public void
normalize()

Implements org.dom4j.Branch.normalize.

Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes.
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.
public boolean
remove(Attribute
is the attribute to be removed
attribute
)

Implements org.dom4j.Element.remove.

Removes the given Attribute from this element.
public boolean
remove(Node
is the given node to be removed
node
)

Overrides org.dom4j.tree.AbstractBranch.remove.

Implements org.dom4j.Branch.remove.

Removes the given Node if the node is an immediate child of this branch.
public boolean
remove(CDATA
is the CDATA to be removed
cdata
)

Implements org.dom4j.Element.remove.

Removes the given CDATA if the node is an immediate child of this element.
public boolean
remove(Comment
is the comment to be removed
comment
)

Overrides org.dom4j.tree.AbstractBranch.remove.

Implements org.dom4j.Branch.remove.

Removes the given Comment if the node is an immediate child of this branch.
public boolean
remove(Element
is the element to be removed
element
)

Overrides org.dom4j.tree.AbstractBranch.remove.

Implements org.dom4j.Branch.remove.

Removes the given Element if the node is an immediate child of this branch.
public boolean
remove(Entity
is the entity to be removed
entity
)

Implements org.dom4j.Element.remove.

Removes the given Entity if the node is an immediate child of this element.
public boolean
remove(Namespace
is the namespace to be removed
namespace
)

Implements org.dom4j.Element.remove.

Removes the given Namespace if the node is an immediate child of this element.
public boolean
remove(ProcessingInstruction
is the processing instruction to be removed
pi
)

Overrides org.dom4j.tree.AbstractBranch.remove.

Implements org.dom4j.Branch.remove.

Removes the given ProcessingInstruction if the node is an immediate child of this branch.
public boolean
remove(Text
is the text to be removed
text
)

Implements org.dom4j.Element.remove.

Removes the given Text if the node is an immediate child of this element.
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
public void
setAttributes(Attributes
DOCUMENT ME!
attributes
,
NamespaceStack
DOCUMENT ME!
namespaceStack
,
boolean
DOCUMENT ME!
noNamespaceAttributes
)

This method provides a more optimal way of setting all the attributes on an Element particularly for use in org.dom4j.io.SAXReader.

public void
setAttributeValue(String
DOCUMENT ME!
name
,
String
DOCUMENT ME!
value
)

Implements org.dom4j.Element.setAttributeValue.

Deprecated As of version 0.5. Please use addAttribute(String, String) instead. WILL BE REMOVED IN dom4j-1.6 !!
DOCUMENT ME!
public void
setAttributeValue(QName
DOCUMENT ME!
qName
,
String
DOCUMENT ME!
value
)

Implements org.dom4j.Element.setAttributeValue.

Deprecated As of version 0.5. Please use addAttribute(String, String) instead. WILL BE REMOVED IN dom4j-1.6 !!
DOCUMENT ME!
public void
setData(Object
DOCUMENT ME!
data
)

Implements org.dom4j.Element.setData.

Sets the data value of this element if this element supports data binding or calls setTextif it doesn't
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.

public void
public void
setText(String
is the new textual value of this node
text
)

Overrides org.dom4j.tree.AbstractNode.setText.

Implements org.dom4j.Node.setText.

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

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(Writer
is the Writer to output the XML to
out
)

Overrides org.dom4j.tree.AbstractNode.write.

Implements org.dom4j.Node.write.

write writes this node as the default XML notation for this node.

Inherited from org.dom4j.tree.AbstractBranch:
addElementaddElementaddElementappendContentcontentcontentListcontentRemovedcreateContentListcreateContentListcreateEmptyListcreateResultListcreateSingleResultListelementByIDelementIDgetContentAsStringValuegetContentAsTextgetTextgetTextTrimhasContentinvalidNodeTypeAddExceptionisReadOnlysetProcessingInstructions