org.dom4j.tree

Class AbstractElement

public abstract class AbstractElement extends AbstractBranch implements Element

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

Version: $Revision: 1.80 $

Author: James Strachan

Field Summary
protected static IteratorEMPTY_ITERATOR
protected static ListEMPTY_LIST
protected static booleanUSE_STRINGVALUE_SEPARATOR
protected static booleanVERBOSE_TOSTRING
Constructor Summary
AbstractElement()
Method Summary
voidaccept(Visitor visitor)

accept method is the Visitor Pattern method.

voidadd(Attribute attribute)
voidadd(Node node)
voidadd(CDATA cdata)
voidadd(Comment comment)
voidadd(Element element)
voidadd(Entity entity)
voidadd(Namespace namespace)
voidadd(ProcessingInstruction pi)
voidadd(Text text)
ElementaddAttribute(String name, String value)
ElementaddAttribute(QName qName, String value)
ElementaddCDATA(String cdata)
ElementaddComment(String comment)
ElementaddElement(String name)
ElementaddEntity(String name, String text)
ListadditionalNamespaces()
ListadditionalNamespaces(String defaultNamespaceURI)
ElementaddNamespace(String prefix, String uri)
protected voidaddNewNode(Node node)
Like addNode() but does not require a parent check
protected voidaddNewNode(int index, Node node)
protected voidaddNode(Node node)
protected voidaddNode(int index, Node node)
ElementaddProcessingInstruction(String target, String data)
ElementaddProcessingInstruction(String target, Map data)
ElementaddText(String text)
voidappendAttributes(Element element)
StringasXML()
Attributeattribute(int index)
Attributeattribute(String name)
Attributeattribute(QName qName)
Attributeattribute(String name, Namespace namespace)
intattributeCount()
IteratorattributeIterator()
protected abstract ListattributeList()
DOCUMENT ME!
protected abstract ListattributeList(int attributeCount)
DOCUMENT ME!
Listattributes()
StringattributeValue(String name)
StringattributeValue(QName qName)
StringattributeValue(String name, String defaultValue)
StringattributeValue(QName qName, String defaultValue)
protected voidchildAdded(Node node)
Called when a new child node is added to create any parent relationships
protected voidchildRemoved(Node node)
protected ListcreateAttributeList()
A Factory Method pattern which creates a List implementation used to store attributes
protected ListcreateAttributeList(int size)
A Factory Method pattern which creates a List implementation used to store attributes
ElementcreateCopy()

This returns a deep clone of this element.

ElementcreateCopy(String name)
ElementcreateCopy(QName qName)
protected ElementcreateElement(String name)
protected ElementcreateElement(QName qName)
protected IteratorcreateSingleIterator(Object result)
ListdeclaredNamespaces()
Elementelement(String name)
Elementelement(QName qName)
Elementelement(String name, Namespace namespace)
IteratorelementIterator()
IteratorelementIterator(String name)
IteratorelementIterator(QName qName)
IteratorelementIterator(String name, Namespace ns)
Listelements()
Listelements(String name)
Listelements(QName qName)
Listelements(String name, Namespace namespace)
StringelementText(String name)
StringelementText(QName qName)
StringelementTextTrim(String name)
StringelementTextTrim(QName qName)
voidensureAttributesCapacity(int minCapacity)
Ensures that the list of attributes has the given size
ObjectgetData()
protected DocumentFactorygetDocumentFactory()
StringgetName()
NamespacegetNamespace()
NamespacegetNamespaceForPrefix(String prefix)
NamespacegetNamespaceForURI(String uri)
StringgetNamespacePrefix()
ListgetNamespacesForURI(String uri)
StringgetNamespaceURI()
shortgetNodeType()
StringgetPath(Element context)
QNamegetQName(String qualifiedName)
StringgetQualifiedName()
StringgetStringValue()
StringgetUniquePath(Element context)
StringgetXPathNameStep()
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().
NodegetXPathResult(int index)
booleanhasMixedContent()
intindexOf(Node node)
booleanisRootElement()
booleanisTextOnly()
Nodenode(int index)
intnodeCount()
IteratornodeIterator()
voidnormalize()
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.
ProcessingInstructionprocessingInstruction(String target)
ListprocessingInstructions()
ListprocessingInstructions(String target)
booleanremove(Attribute attribute)
booleanremove(Node node)
booleanremove(CDATA cdata)
booleanremove(Comment comment)
booleanremove(Element element)
booleanremove(Entity entity)
booleanremove(Namespace namespace)
booleanremove(ProcessingInstruction pi)
booleanremove(Text text)
protected booleanremoveNode(Node node)
booleanremoveProcessingInstruction(String target)
voidsetAttributes(Attributes attributes, NamespaceStack namespaceStack, boolean noNamespaceAttributes)
This method provides a more optimal way of setting all the attributes on an Element particularly for use in {@link org.dom4j.io.SAXReader}.
voidsetAttributeValue(String name, String value)
DOCUMENT ME!
voidsetAttributeValue(QName qName, String value)
DOCUMENT ME!
voidsetData(Object data)
voidsetName(String name)
voidsetNamespace(Namespace namespace)
voidsetText(String text)
StringtoString()
voidwrite(Writer out)

Field Detail

EMPTY_ITERATOR

protected static final Iterator EMPTY_ITERATOR

EMPTY_LIST

protected static final List EMPTY_LIST

USE_STRINGVALUE_SEPARATOR

protected static final boolean USE_STRINGVALUE_SEPARATOR

VERBOSE_TOSTRING

protected static final boolean VERBOSE_TOSTRING

Constructor Detail

AbstractElement

public AbstractElement()

Method Detail

accept

public void accept(Visitor visitor)

accept method is the Visitor Pattern method.

Parameters: visitor Visitor is the visitor.

add

public void add(Attribute attribute)

add

public void add(Node node)

add

public void add(CDATA cdata)

add

public void add(Comment comment)

add

public void add(Element element)

add

public void add(Entity entity)

add

public void add(Namespace namespace)

add

public void add(ProcessingInstruction pi)

add

public void add(Text text)

addAttribute

public Element addAttribute(String name, String value)

addAttribute

public Element addAttribute(QName qName, String value)

addCDATA

public Element addCDATA(String cdata)

addComment

public Element addComment(String comment)

addElement

public Element addElement(String name)

addEntity

public Element addEntity(String name, String text)

additionalNamespaces

public List additionalNamespaces()

additionalNamespaces

public List additionalNamespaces(String defaultNamespaceURI)

addNamespace

public Element addNamespace(String prefix, String uri)

addNewNode

protected void addNewNode(Node node)
Like addNode() but does not require a parent check

Parameters: node DOCUMENT ME!

addNewNode

protected void addNewNode(int index, Node node)

addNode

protected void addNode(Node node)

addNode

protected void addNode(int index, Node node)

addProcessingInstruction

public Element addProcessingInstruction(String target, String data)

addProcessingInstruction

public Element addProcessingInstruction(String target, Map data)

addText

public Element addText(String text)

appendAttributes

public void appendAttributes(Element element)

asXML

public String asXML()

attribute

public Attribute attribute(int index)

attribute

public Attribute attribute(String name)

attribute

public Attribute attribute(QName qName)

attribute

public Attribute attribute(String name, Namespace namespace)

attributeCount

public int attributeCount()

attributeIterator

public Iterator attributeIterator()

attributeList

protected abstract List attributeList()
DOCUMENT ME!

Returns: the internal List used to store attributes or creates one if one is not available

attributeList

protected abstract List attributeList(int attributeCount)
DOCUMENT ME!

Parameters: attributeCount DOCUMENT ME!

Returns: the internal List used to store attributes or creates one with the specified size if one is not available

attributes

public List attributes()

attributeValue

public String attributeValue(String name)

attributeValue

public String attributeValue(QName qName)

attributeValue

public String attributeValue(String name, String defaultValue)

attributeValue

public String attributeValue(QName qName, String defaultValue)

childAdded

protected void childAdded(Node node)
Called when a new child node is added to create any parent relationships

Parameters: node DOCUMENT ME!

childRemoved

protected void childRemoved(Node node)

createAttributeList

protected List createAttributeList()
A Factory Method pattern which creates a List implementation used to store attributes

Returns: DOCUMENT ME!

createAttributeList

protected List createAttributeList(int size)
A Factory Method pattern which creates a List implementation used to store attributes

Parameters: size DOCUMENT ME!

Returns: DOCUMENT ME!

createCopy

public Element createCopy()

This returns a deep clone of this element. The new element is detached from its parent, and getParent() on the clone will return null.

Returns: the clone of this element

createCopy

public Element createCopy(String name)

createCopy

public Element createCopy(QName qName)

createElement

protected Element createElement(String name)

createElement

protected Element createElement(QName qName)

createSingleIterator

protected Iterator createSingleIterator(Object result)

declaredNamespaces

public List declaredNamespaces()

element

public Element element(String name)

element

public Element element(QName qName)

element

public Element element(String name, Namespace namespace)

elementIterator

public Iterator elementIterator()

elementIterator

public Iterator elementIterator(String name)

elementIterator

public Iterator elementIterator(QName qName)

elementIterator

public Iterator elementIterator(String name, Namespace ns)

elements

public List elements()

elements

public List elements(String name)

elements

public List elements(QName qName)

elements

public List elements(String name, Namespace namespace)

elementText

public String elementText(String name)

elementText

public String elementText(QName qName)

elementTextTrim

public String elementTextTrim(String name)

elementTextTrim

public String elementTextTrim(QName qName)

ensureAttributesCapacity

public void ensureAttributesCapacity(int minCapacity)
Ensures that the list of attributes has the given size

Parameters: minCapacity DOCUMENT ME!

getData

public Object getData()

getDocumentFactory

protected DocumentFactory getDocumentFactory()

getName

public String getName()

getNamespace

public Namespace getNamespace()

getNamespaceForPrefix

public Namespace getNamespaceForPrefix(String prefix)

getNamespaceForURI

public Namespace getNamespaceForURI(String uri)

getNamespacePrefix

public String getNamespacePrefix()

getNamespacesForURI

public List getNamespacesForURI(String uri)

getNamespaceURI

public String getNamespaceURI()

getNodeType

public short getNodeType()

getPath

public String getPath(Element context)

getQName

public QName getQName(String qualifiedName)

getQualifiedName

public String getQualifiedName()

getStringValue

public String getStringValue()

getUniquePath

public String getUniquePath(Element context)

getXPathNameStep

public String 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().

Returns: DOCUMENT ME!

getXPathResult

public Node getXPathResult(int index)

hasMixedContent

public boolean hasMixedContent()

indexOf

public int indexOf(Node node)

isRootElement

public boolean isRootElement()

isTextOnly

public boolean isTextOnly()

node

public Node node(int index)

nodeCount

public int nodeCount()

nodeIterator

public Iterator nodeIterator()

normalize

public void 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. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.

Since: DOM Level 2

processingInstruction

public ProcessingInstruction processingInstruction(String target)

processingInstructions

public List processingInstructions()

processingInstructions

public List processingInstructions(String target)

remove

public boolean remove(Attribute attribute)

remove

public boolean remove(Node node)

remove

public boolean remove(CDATA cdata)

remove

public boolean remove(Comment comment)

remove

public boolean remove(Element element)

remove

public boolean remove(Entity entity)

remove

public boolean remove(Namespace namespace)

remove

public boolean remove(ProcessingInstruction pi)

remove

public boolean remove(Text text)

removeNode

protected boolean removeNode(Node node)

removeProcessingInstruction

public boolean removeProcessingInstruction(String target)

setAttributes

public void setAttributes(Attributes attributes, NamespaceStack namespaceStack, boolean noNamespaceAttributes)
This method provides a more optimal way of setting all the attributes on an Element particularly for use in {@link org.dom4j.io.SAXReader}.

Parameters: attributes DOCUMENT ME! namespaceStack DOCUMENT ME! noNamespaceAttributes DOCUMENT ME!

setAttributeValue

public void setAttributeValue(String name, String value)

Deprecated: As of version 0.5. Please use {@link #addAttribute(String,String)} instead. WILL BE REMOVED IN dom4j-1.6 !!

DOCUMENT ME!

Parameters: name DOCUMENT ME! value DOCUMENT ME!

setAttributeValue

public void setAttributeValue(QName qName, String value)

Deprecated: As of version 0.5. Please use {@link #addAttribute(String,String)} instead. WILL BE REMOVED IN dom4j-1.6 !!

DOCUMENT ME!

Parameters: qName DOCUMENT ME! value DOCUMENT ME!

setData

public void setData(Object data)

setName

public void setName(String name)

setNamespace

public void setNamespace(Namespace namespace)

setText

public void setText(String text)

toString

public String toString()

write

public void write(Writer out)
Copyright B) 2005 MetaStuff Ltd. All Rights Reserved. Hosted by

SourceForge