|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
org.dom4j.tree.AbstractElement
org.dom4j.tree.DefaultElement
DefaultElement is the default DOM4J default implementation of
an XML element.
| Field Summary |
| Fields inherited from class org.dom4j.tree.AbstractElement |
EMPTY_ITERATOR, EMPTY_LIST, USE_STRINGVALUE_SEPARATOR, VERBOSE_TOSTRING |
| Fields inherited from class org.dom4j.tree.AbstractBranch |
DEFAULT_CONTENT_LIST_SIZE, outputFormat |
| Fields inherited from class org.dom4j.tree.AbstractNode |
NODE_TYPE_NAMES |
| Fields inherited from interface org.dom4j.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 | |
DefaultElement(QName qname)
|
|
DefaultElement(QName qname,
int attributeCount)
|
|
DefaultElement(java.lang.String name)
|
|
DefaultElement(java.lang.String name,
Namespace namespace)
|
|
| Method Summary | |
void |
add(Attribute attribute)
Adds the given Attribute to this element. |
java.util.List |
additionalNamespaces()
Returns any additional namespaces declarations for this element other than namespace returned via the AbstractElement.getNamespace() method. |
java.util.List |
additionalNamespaces(java.lang.String defaultNamespaceURI)
|
protected void |
addNewNode(Node node)
Like addNode() but does not require a parent check |
Attribute |
attribute(int index)
Returns the attribute at the specified indexGets the |
Attribute |
attribute(QName qName)
|
Attribute |
attribute(java.lang.String name)
Returns the attribute with the given name |
Attribute |
attribute(java.lang.String name,
Namespace namespace)
|
int |
attributeCount()
|
java.util.Iterator |
attributeIterator()
|
protected java.util.List |
attributeList()
|
protected java.util.List |
attributeList(int size)
|
java.util.List |
attributes()
Returns the Attribute instances this element contains as
a backed List so that the attributes may be modified directly
using the List interface. |
void |
clearContent()
Clears the content for this branch, removing any Node
instances this branch may contain. |
java.lang.Object |
clone()
clone will return a deep clone or if this node is
read-only then clone will return the same instance. |
protected java.util.List |
contentList()
|
java.util.List |
declaredNamespaces()
Returns all the namespaces declared by this element. |
Element |
element(QName qName)
Returns the first element for the given fully qualified name. |
Element |
element(java.lang.String name)
Returns the first element for the given local name and any namespace. |
Element |
element(java.lang.String name,
Namespace namespace)
|
Document |
getDocument()
getDocument returns the Document
that this Node is part of if this node supports
the parent relationship. |
protected DocumentFactory |
getDocumentFactory()
|
Namespace |
getNamespaceForPrefix(java.lang.String prefix)
Returns the Namespace which is mapped to the given
prefix or null if it could not be found. |
Namespace |
getNamespaceForURI(java.lang.String uri)
Returns the Namespace which is mapped to the given
URI or null if it could not be found. |
Element |
getParent()
getParent returns the parent Element
if this node supports the parent relationship or null if it is
the root element or does not support the parent relationship. |
QName |
getQName()
Returns the QName of this element which represents
the local name, the qualified name and the Namespace. |
java.lang.String |
getStringValue()
Returns the XPath string-value of this node. |
java.lang.String |
getText()
Returns the text value of this element without recursing through child elements. |
int |
indexOf(Node node)
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. |
Node |
node(int index)
Returns the Node at the specified index position. |
int |
nodeCount()
Returns the number of Node instances that this branch
contains. |
java.util.Iterator |
nodeIterator()
Returns an iterator through the content nodes of this branch |
ProcessingInstruction |
processingInstruction(java.lang.String target)
|
java.util.List |
processingInstructions()
Returns a list of all the processing instructions in this branch. |
java.util.List |
processingInstructions(java.lang.String target)
Returns a list of the processing instructions for the given target. |
boolean |
remove(Attribute attribute)
Removes the given Attribute from this element. |
protected boolean |
removeNode(Node node)
|
boolean |
removeProcessingInstruction(java.lang.String target)
Removes the processing instruction for the given target if it exists |
protected void |
setAttributeList(java.util.List attributes)
|
void |
setAttributes(java.util.List attributes)
Sets the attributes that this element contains |
void |
setContent(java.util.List content)
Sets the contents of this branch as a List of
Node instances. |
void |
setDocument(Document document)
setDocument sets the document of this node if the
parent relationship is supported or does nothing if the parent
relationship is not supported. |
void |
setParent(Element parent)
setParent sets the parent relationship of
this node if the parent relationship is supported or does nothing
if the parent relationship is not supported. |
void |
setQName(QName qname)
Sets the QName of this element which represents
the local name, the qualified name and the Namespace. |
boolean |
supportsParent()
supportsParent returns true if this node supports the
parent relationship. |
| Methods inherited from class org.dom4j.tree.AbstractBranch |
addElement, addElement, addElement, appendContent, content, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getTextTrim, hasContent, invalidNodeTypeAddException, isReadOnly, setProcessingInstructions |
| Methods inherited from class org.dom4j.tree.AbstractNode |
asXPathResult, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getNodeTypeName, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, valueOf |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.dom4j.Element |
getTextTrim |
| Methods inherited from interface org.dom4j.Branch |
addElement, addElement, appendContent, content, elementByID, setProcessingInstructions |
| Methods inherited from interface org.dom4j.Node |
asXPathResult, createXPath, detach, getNodeTypeName, getPath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, valueOf |
| Constructor Detail |
public DefaultElement(java.lang.String name)
public DefaultElement(QName qname)
public DefaultElement(QName qname,
int attributeCount)
public DefaultElement(java.lang.String name,
Namespace namespace)
| Method Detail |
public Element getParent()
NodegetParent returns the parent Element
if this node supports the parent relationship or null if it is
the root element or does not support the parent relationship.
This method is an optional feature and may not be supported
for all Node implementations.
getParent in interface NodegetParent in class AbstractNodepublic void setParent(Element parent)
NodesetParent sets the parent relationship of
this node if the parent relationship is supported or does nothing
if the parent relationship is not supported.
This method should only be called from inside an
Element implementation method and is not intended for
general use.
setParent in interface NodesetParent in class AbstractNodepublic Document getDocument()
NodegetDocument returns the Document
that this Node is part of if this node supports
the parent relationship.
This method is an optional feature and may not be supported
for all Node implementations.
getDocument in interface NodegetDocument in class AbstractNodepublic void setDocument(Document document)
NodesetDocument sets the document of this node if the
parent relationship is supported or does nothing if the parent
relationship is not supported.
This method should only be called from inside a
Document implementation method and is not intended for
general use.
setDocument in interface NodesetDocument in class AbstractNodepublic boolean supportsParent()
NodesupportsParent returns true if this node supports the
parent relationship.
Some XML tree implementations are singly linked and only support downward navigation through children relationships. The default case is that both parent and children relationships are supported though for memory and performance reasons the parent relationship may not be supported.
supportsParent in interface NodesupportsParent in class AbstractNodepublic QName getQName()
ElementReturns the QName of this element which represents
the local name, the qualified name and the Namespace.
QName associated with this elementpublic void setQName(QName qname)
ElementSets the QName of this element which represents
the local name, the qualified name and the Namespace.
qname - is the QName to be associated with this elementpublic java.lang.String getText()
ElementText, CDATA and
Entity nodes that this element contains
and appends the text values together.
getText in interface ElementgetText in class AbstractBranchpublic java.lang.String getStringValue()
ElementText, CDATA, Entity and Element nodes
all appended together.
getStringValue in interface ElementgetStringValue in class AbstractElementpublic java.lang.Object clone()
Nodeclone will return a deep clone or if this node is
read-only then clone will return the same instance.
clone in interface Nodeclone in class AbstractNodepublic Namespace getNamespaceForPrefix(java.lang.String prefix)
ElementReturns the Namespace which is mapped to the given
prefix or null if it could not be found.
getNamespaceForPrefix in interface ElementgetNamespaceForPrefix in class AbstractElementpublic Namespace getNamespaceForURI(java.lang.String uri)
ElementReturns the Namespace which is mapped to the given
URI or null if it could not be found. If there is more than one
Namespace mapped to the URI, which of them will be
returned is undetermined.
getNamespaceForURI in interface ElementgetNamespaceForURI in class AbstractElementpublic java.util.List declaredNamespaces()
ElementReturns all the namespaces declared by this element. If no namespaces are declared for this element then an empty list will be returned. The list is backed by the element such that changes to the list will be reflected in the element though the reverse is not the case.
declaredNamespaces in interface ElementdeclaredNamespaces in class AbstractElementpublic java.util.List additionalNamespaces()
ElementReturns any additional namespaces declarations for this element
other than namespace returned via the Element.getNamespace() method.
If no additional namespace declarations are present for this
element then an empty list will be returned.
The list is backed by the element such that changes to the list will
be reflected in the element though the reverse is not the case.
additionalNamespaces in interface ElementadditionalNamespaces in class AbstractElementpublic java.util.List additionalNamespaces(java.lang.String defaultNamespaceURI)
additionalNamespaces in class AbstractElementpublic java.util.List processingInstructions()
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.
processingInstructions in interface BranchprocessingInstructions in class AbstractElementpublic java.util.List processingInstructions(java.lang.String target)
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.
processingInstructions in interface BranchprocessingInstructions in class AbstractElementpublic ProcessingInstruction processingInstruction(java.lang.String target)
processingInstruction in interface BranchprocessingInstruction in class AbstractElementpublic boolean removeProcessingInstruction(java.lang.String target)
Branch
removeProcessingInstruction in interface BranchremoveProcessingInstruction in class AbstractElementpublic Element element(java.lang.String name)
Element
element in interface Elementelement in class AbstractElementpublic Element element(QName qName)
Element
element in interface Elementelement in class AbstractElement
public Element element(java.lang.String name,
Namespace namespace)
element in class AbstractElementpublic void setContent(java.util.List content)
BranchList of
Node instances.
content - is the list of nodes to use as the content for this
branch.public void clearContent()
BranchNode
instances this branch may contain.
public Node node(int index)
BranchNode at the specified index position.
node in interface Branchnode in class AbstractElementpublic int indexOf(Node node)
Branch
indexOf in interface BranchindexOf in class AbstractElementpublic int nodeCount()
BranchNode instances that this branch
contains.
nodeCount in interface BranchnodeCount in class AbstractElementpublic java.util.Iterator nodeIterator()
Branch
nodeIterator in interface BranchnodeIterator in class AbstractElementpublic java.util.List attributes()
ElementReturns the Attribute instances this element contains as
a backed List so that the attributes may be modified directly
using the List interface.
The List is backed by the Element so that
changes to the list are reflected in the element and vice versa.
attributes in interface Elementattributes in class AbstractElementpublic void setAttributes(java.util.List attributes)
Element
public java.util.Iterator attributeIterator()
attributeIterator in interface ElementattributeIterator in class AbstractElementpublic Attribute attribute(int index)
Element
attribute in interface Elementattribute in class AbstractElementpublic int attributeCount()
attributeCount in interface ElementattributeCount in class AbstractElementpublic Attribute attribute(java.lang.String name)
Element
attribute in interface Elementattribute in class AbstractElementpublic Attribute attribute(QName qName)
attribute in interface Elementattribute in class AbstractElement
public Attribute attribute(java.lang.String name,
Namespace namespace)
attribute in class AbstractElementpublic void add(Attribute attribute)
ElementAttribute to this element.
If the given node already has a parent defined then an
IllegalAddException will be thrown.
Attributes with null values are silently ignored.
If the value of the attribute is null then this method call will
remove any attributes with the QName of this attribute.
add in interface Elementadd in class AbstractElementpublic boolean remove(Attribute attribute)
ElementAttribute from this element.
remove in interface Elementremove in class AbstractElementprotected void addNewNode(Node node)
AbstractElement
addNewNode in class AbstractElementprotected boolean removeNode(Node node)
removeNode in class AbstractElementprotected java.util.List contentList()
contentList in class AbstractBranchprotected java.util.List attributeList()
attributeList in class AbstractElementprotected java.util.List attributeList(int size)
attributeList in class AbstractElementprotected void setAttributeList(java.util.List attributes)
protected DocumentFactory getDocumentFactory()
getDocumentFactory in class AbstractElement
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||