|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.dom4j.tree Class DefaultElement
java.lang.Objectorg.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
org.dom4j.tree.AbstractElement
org.dom4j.tree.DefaultElement
- All Implemented Interfaces:
- Branch, Cloneable, Element, Node, Serializable
- Direct Known Subclasses:
- BeanElement, DatatypeElement, DOMElement, IndexedElement, UserDataElement
- public class DefaultElement
- extends AbstractElement
DefaultElement is the default DOM4J default implementation of
an XML element.
- Version:
- $Revision: 1.59 $
- Author:
- James Strachan
- See Also:
- Serialized Form
| 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 |
| 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(String name)
|
|
DefaultElement(String name,
Namespace namespace)
|
|
| Method Summary | |
void |
add(Attribute attribute)
Adds the given Attribute to this element. |
List |
additionalNamespaces()
Returns any additional namespaces declarations for this element other than namespace returned via the AbstractElement.getNamespace()method. |
List |
additionalNamespaces(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)
DOCUMENT ME! |
Attribute |
attribute(String name)
Returns the attribute with the given name |
Attribute |
attribute(String name,
Namespace namespace)
|
int |
attributeCount()
DOCUMENT ME! |
Iterator |
attributeIterator()
DOCUMENT ME! |
protected List |
attributeList()
DOCUMENT ME! |
protected List |
attributeList(int size)
DOCUMENT ME! |
List |
attributes()
Returns the Attributeinstances this element contains as a backed
Listso that the attributes may be modified directly using the
Listinterface. |
void |
clearContent()
Clears the content for this branch, removing any Node
instances this branch may contain. |
Object |
clone()
clone will return a deep clone or if this node is
read-only then clone will return the same instance.
|
protected List |
contentList()
DOCUMENT ME! |
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(String name)
Returns the first element for the given local name and any namespace. |
Element |
element(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(String prefix)
Returns the Namespace which is mapped to the given prefix
or null if it could not be found.
|
Namespace |
getNamespaceForURI(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.
|
String |
getStringValue()
Returns the XPath string-value of this node. |
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. |
Iterator |
nodeIterator()
Returns an iterator through the content nodes of this branch |
ProcessingInstruction |
processingInstruction(String target)
DOCUMENT ME! |
List |
processingInstructions()
Returns a list of all the processing instructions in this branch. |
List |
processingInstructions(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(String target)
Removes the processing instruction for the given target if it exists |
protected void |
setAttributeList(List attributeList)
|
void |
setAttributes(List attributes)
Sets the attributes that this element contains |
void |
setContent(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 name)
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 |
DefaultElement
public DefaultElement(String name)
DefaultElement
public DefaultElement(QName qname)
DefaultElement
public DefaultElement(QName qname, int attributeCount)
DefaultElement
public DefaultElement(String name, Namespace namespace)
| Method Detail |
getParent
public Element getParent()
- Description copied from interface:
Node getParentreturns the parentElementif 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
Nodeimplementations.- Specified by:
getParentin interfaceNode- Overrides:
getParentin classAbstractNode
setParent
public void setParent(Element parent)
- Description copied from interface:
Node setParentsets 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
Elementimplementation method and is not intended for general use.- Specified by:
setParentin interfaceNode- Overrides:
setParentin classAbstractNode
getDocument
public Document getDocument()
- Description copied from interface:
Node getDocumentreturns theDocumentthat thisNodeis part of if this node supports the parent relationship.This method is an optional feature and may not be supported for all
Nodeimplementations.- Specified by:
getDocumentin interfaceNode- Overrides:
getDocumentin classAbstractNode
setDocument
public void setDocument(Document document)
- Description copied from interface:
Node setDocumentsets 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
Documentimplementation method and is not intended for general use.- Specified by:
setDocumentin interfaceNode- Overrides:
setDocumentin classAbstractNode
supportsParent
public boolean supportsParent()
- Description copied from interface:
Node supportsParentreturns 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.
- Specified by:
supportsParentin interfaceNode- Overrides:
supportsParentin classAbstractNode
getQName
public QName getQName()
- Description copied from interface:
Element Returns the
QNameof this element which represents the local name, the qualified name and theNamespace.- Returns:
- the
QNameassociated with this element
setQName
public void setQName(QName name)
- Description copied from interface:
Element Sets the
QNameof this element which represents the local name, the qualified name and theNamespace.- Parameters:
name- is theQNameto be associated with this element
getText
public String getText()
- Description copied from interface:
Element - Returns the text value of this element without recursing through child
elements. This method iterates through all
Text,CDATAandEntitynodes that this element contains and appends the text values together. - Specified by:
getTextin interfaceElement- Overrides:
getTextin classAbstractBranch
getStringValue
public String getStringValue()
- Description copied from interface:
Element - Returns the XPath string-value of this node. The behaviour of this method
is defined in the XPath
specification . This method returns the string-value of all the
contained
Text,CDATA,EntityandElementnodes all appended together. - Specified by:
getStringValuein interfaceElement- Overrides:
getStringValuein classAbstractElement
clone
public Object clone()
- Description copied from interface:
Node clonewill 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
getNamespaceForPrefix
public Namespace getNamespaceForPrefix(String prefix)
- Description copied from interface:
Element Returns the
Namespacewhich is mapped to the given prefix or null if it could not be found.- Specified by:
getNamespaceForPrefixin interfaceElement- Overrides:
getNamespaceForPrefixin classAbstractElement
getNamespaceForURI
public Namespace getNamespaceForURI(String uri)
- Description copied from interface:
Element Returns the
Namespacewhich is mapped to the given URI or null if it could not be found. If there is more than oneNamespacemapped to the URI, which of them will be returned is undetermined.- Specified by:
getNamespaceForURIin interfaceElement- Overrides:
getNamespaceForURIin classAbstractElement
declaredNamespaces
public List declaredNamespaces()
- Description copied from interface:
Element Returns 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.
- Specified by:
declaredNamespacesin interfaceElement- Overrides:
declaredNamespacesin classAbstractElement
additionalNamespaces
public List additionalNamespaces()
- Description copied from interface:
Element Returns 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.- Specified by:
additionalNamespacesin interfaceElement- Overrides:
additionalNamespacesin classAbstractElement
additionalNamespaces
public List additionalNamespaces(String defaultNamespaceURI)
- Overrides:
additionalNamespacesin classAbstractElement
processingInstructions
public List processingInstructions()
- Description copied from interface:
Branch 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.
- Specified by:
processingInstructionsin interfaceBranch- Overrides:
processingInstructionsin classAbstractElement
processingInstructions
public List processingInstructions(String target)
- Description copied from interface:
Branch 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.
- Specified by:
processingInstructionsin interfaceBranch- Overrides:
processingInstructionsin classAbstractElement
processingInstruction
public ProcessingInstruction processingInstruction(String target)
- Description copied from interface:
Branch - DOCUMENT ME!
- Specified by:
processingInstructionin interfaceBranch- Overrides:
processingInstructionin classAbstractElement
removeProcessingInstruction
public boolean removeProcessingInstruction(String target)
- Description copied from interface:
Branch - Removes the processing instruction for the given target if it exists
- Specified by:
removeProcessingInstructionin interfaceBranch- Overrides:
removeProcessingInstructionin classAbstractElement
element
public Element element(String name)
- Description copied from interface:
Element - Returns the first element for the given local name and any namespace.
- Specified by:
elementin interfaceElement- Overrides:
elementin classAbstractElement
element
public Element element(QName qName)
- Description copied from interface:
Element - Returns the first element for the given fully qualified name.
- Specified by:
elementin interfaceElement- Overrides:
elementin classAbstractElement
element
public Element element(String name, Namespace namespace)
- Overrides:
elementin classAbstractElement
setContent
public void setContent(List content)
- Description copied from interface:
Branch - Sets the contents of this branch as a
ListofNodeinstances. - Parameters:
content- is the list of nodes to use as the content for this branch.
clearContent
public void clearContent()
- Description copied from interface:
Branch - Clears the content for this branch, removing any
Nodeinstances this branch may contain.
node
public Node node(int index)
- Description copied from interface:
Branch - Returns the
Nodeat the specified index position. - Specified by:
nodein interfaceBranch- Overrides:
nodein classAbstractElement
indexOf
public int indexOf(Node node)
- Description copied from interface:
Branch - 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.
- Specified by:
indexOfin interfaceBranch- Overrides:
indexOfin classAbstractElement
nodeCount
public int nodeCount()
- Description copied from interface:
Branch - Returns the number of
Nodeinstances that this branch contains. - Specified by:
nodeCountin interfaceBranch- Overrides:
nodeCountin classAbstractElement
nodeIterator
public Iterator nodeIterator()
- Description copied from interface:
Branch - Returns an iterator through the content nodes of this branch
- Specified by:
nodeIteratorin interfaceBranch- Overrides:
nodeIteratorin classAbstractElement
attributes
public List attributes()
- Description copied from interface:
Element Returns the
Attributeinstances this element contains as a backedListso that the attributes may be modified directly using theListinterface. TheListis backed by theElementso that changes to the list are reflected in the element and vice versa.- Specified by:
attributesin interfaceElement- Overrides:
attributesin classAbstractElement
setAttributes
public void setAttributes(List attributes)
- Description copied from interface:
Element - Sets the attributes that this element contains
- Parameters:
attributes- DOCUMENT ME!
attributeIterator
public Iterator attributeIterator()
- Description copied from interface:
Element - DOCUMENT ME!
- Specified by:
attributeIteratorin interfaceElement- Overrides:
attributeIteratorin classAbstractElement
attribute
public Attribute attribute(int index)
- Description copied from interface:
Element - Returns the attribute at the specified indexGets the
- Specified by:
attributein interfaceElement- Overrides:
attributein classAbstractElement
attributeCount
public int attributeCount()
- Description copied from interface:
Element - DOCUMENT ME!
- Specified by:
attributeCountin interfaceElement- Overrides:
attributeCountin classAbstractElement
attribute
public Attribute attribute(String name)
- Description copied from interface:
Element - Returns the attribute with the given name
- Specified by:
attributein interfaceElement- Overrides:
attributein classAbstractElement
attribute
public Attribute attribute(QName qName)
- Description copied from interface:
Element - DOCUMENT ME!
- Specified by:
attributein interfaceElement- Overrides:
attributein classAbstractElement
attribute
public Attribute attribute(String name, Namespace namespace)
- Overrides:
attributein classAbstractElement
add
public void add(Attribute attribute)
- Description copied from interface:
Element - Adds the given
Attributeto this element. If the given node already has a parent defined then anIllegalAddExceptionwill 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.
- Specified by:
addin interfaceElement- Overrides:
addin classAbstractElement
remove
public boolean remove(Attribute attribute)
- Description copied from interface:
Element - Removes the given
Attributefrom this element. - Specified by:
removein interfaceElement- Overrides:
removein classAbstractElement
addNewNode
protected void addNewNode(Node node)
- Description copied from class:
AbstractElement - Like addNode() but does not require a parent check
- Overrides:
addNewNodein classAbstractElement
- Parameters:
node- DOCUMENT ME!
removeNode
protected boolean removeNode(Node node)
- Overrides:
removeNodein classAbstractElement
contentList
protected List contentList()
- Description copied from class:
AbstractBranch - DOCUMENT ME!
- Specified by:
contentListin classAbstractBranch
- Returns:
- the internal List used to manage the content
attributeList
protected List attributeList()
- Description copied from class:
AbstractElement - DOCUMENT ME!
- Specified by:
attributeListin classAbstractElement
- Returns:
- the internal List used to store attributes or creates one if one is not available
attributeList
protected List attributeList(int size)
- Description copied from class:
AbstractElement - DOCUMENT ME!
- Specified by:
attributeListin classAbstractElement
- Parameters:
size- DOCUMENT ME!- Returns:
- the internal List used to store attributes or creates one with the specified size if one is not available
setAttributeList
protected void setAttributeList(List attributeList)
getDocumentFactory
protected DocumentFactory getDocumentFactory()
- Overrides:
getDocumentFactoryin classAbstractElement
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Copyright © 2001-2005 MetaStuff Ltd.. All Rights Reserved.
