Class AbstractElement
- All Implemented Interfaces:
Serializable, Cloneable, Branch, Element, Node
- Direct Known Subclasses:
BaseElement, DefaultElement
AbstractElement is an abstract base class for tree
implementors to use for implementation inheritence.
- Version:
- $Revision: 1.80 $
- Author:
- James Strachan
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final booleanprotected static final booleanFields inherited from class AbstractBranch
DEFAULT_CONTENT_LIST_SIZEFields inherited from class AbstractNode
NODE_TYPE_NAMESFields inherited from interface 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidacceptmethod is theVisitor Patternmethod.voidAdds the givenAttributeto this element.voidAdds the givenCDATAto this element.voidAdds the givenCommentto this branch.voidAdds the givenElementto this branch.voidAdds the givenEntityto this element.voidAdds the givenNamespaceto this element.voidAdds the givenNodeor throwsIllegalAddExceptionif the given node is not of a valid type.voidAdds the givenProcessingInstructionto this branch.voidAdds the givenTextto this element.addAttribute(String name, String value) Adds the attribute value of the given local name.addAttribute(QName qName, String value) Adds the attribute value of the given fully qualified name.Adds a newCDATAnode with the given text to this element.addComment(String comment) Adds a newCommentnode with the given text to this element.addElement(String name) Adds a newElementnode with the given name to this branch and returns a reference to the new node.Adds a newEntitynode with the given name and text to this element and returns a reference to the new node.Returns any additional namespaces declarations for this element other than namespace returned via theElement.getNamespace()method.additionalNamespaces(String defaultNamespaceURI) addNamespace(String prefix, String uri) Adds a namespace to this element for use by its child contentprotected voidaddNewNode(int index, Node node) protected voidaddNewNode(Node node) Like addNode() but does not require a parent checkprotected voidprotected voidaddProcessingInstruction(String target, String data) Adds a processing instruction for the given targetaddProcessingInstruction(String target, Map<String, String> data) Adds a processing instruction for the given targetAdds a newTextnode with the given text to this element.voidappendAttributes(Element element) Appends the attributes of the given element to me.asXML()asXMLreturns the textual XML representation of this node.attribute(int index) Returns the attribute at the specified indexGets theReturns the attribute with the given nameDOCUMENT ME!intDOCUMENT ME!DOCUMENT ME!DOCUMENT ME!attributeList(int attributeCount) DOCUMENT ME!attributeValue(String name) 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.attributeValue(String name, String defaultValue) 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.attributeValue(QName qName) 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.attributeValue(QName qName, String defaultValue) 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 voidchildAdded(Node node) Called when a new child node is added to create any parent relationshipsprotected voidchildRemoved(Node node) Called when a child node has been removed to allow any parent relationships to be deleted or events to be fired.A Factory Method pattern which creates a List implementation used to store attributescreateAttributeList(int size) A Factory Method pattern which creates a List implementation used to store attributesThis returns a deep clone of this element.createCopy(String name) 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.createCopy(QName qName) Creates a deep copy of this element with the given fully qualified name.protected ElementcreateElement(String name) protected ElementcreateElement(QName qName) protected <T> Iterator<T> createSingleIterator(T result) Returns all the namespaces declared by this element.Returns the first element for the given local name and any namespace.Returns the first element for the given fully qualified name.Returns an iterator over all this elements child elements.elementIterator(String name) Returns an iterator over the elements contained in this element which match the given local name and any namespace.elementIterator(String name, Namespace ns) elementIterator(QName qName) Returns an iterator over the elements contained in this element which match the given fully qualified name.elements()Returns the elements contained in this element.Returns the elements contained in this element with the given local name and any namespace.Returns the elements contained in this element with the given fully qualified name.elementText(String name) elementText(QName qName) elementTextTrim(String name) elementTextTrim(QName qName) voidensureAttributesCapacity(int minCapacity) Ensures that the list of attributes has the given sizegetData()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 asElement.getText()protected DocumentFactorygetName()getNamereturns the name of this node.Returns theNamespaceof this element if one exists otherwiseNamespace.NO_NAMESPACEis returned.getNamespaceForPrefix(String prefix) Returns theNamespacewhich is mapped to the given prefix or null if it could not be found.getNamespaceForURI(String uri) Returns theNamespacewhich is mapped to the given URI or null if it could not be found.Returns the namespace prefix of this element if one exists otherwise an emptyStringis returned.Returns the all namespaces which are mapped to the given URI or an empty list if no such namespaces could be found.Returns the URI mapped to the namespace of this element if one exists otherwise an emptyStringis returned.shortReturns the code according to the type of node.Returns the relative XPath expression which will return a node set containing the given node such as a/b/@c.Returns theQNamefor 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.Returns the fully qualified name of this element.Returns the XPath string-value of this node.getUniquePath(Element context) Returns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node.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().getXPathResult(int index) Returns a node at the given index suitable for an XPath result set.booleanReturns true if thisElementhas mixed content.intReturns 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.booleanDOCUMENT ME!booleanReturns true if thisElementhas text only content.node(int index) Returns theNodeat the specified index position.intReturns the number ofNodeinstances that this branch contains.Returns an iterator through the content nodes of this branchvoidPuts allTextnodes in the full depth of the sub-tree underneath thisNode, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes.processingInstruction(String target) DOCUMENT ME!Returns a list of all the processing instructions in this branch.processingInstructions(String target) Returns a list of the processing instructions for the given target.booleanRemoves the givenAttributefrom this element.booleanRemoves the givenCDATAif the node is an immediate child of this element.booleanRemoves the givenCommentif the node is an immediate child of this branch.booleanRemoves the givenElementif the node is an immediate child of this branch.booleanRemoves the givenEntityif the node is an immediate child of this element.booleanRemoves the givenNamespaceif the node is an immediate child of this element.booleanRemoves the givenNodeif the node is an immediate child of this branch.booleanRemoves the givenProcessingInstructionif the node is an immediate child of this branch.booleanRemoves the givenTextif the node is an immediate child of this element.protected booleanremoveNode(Node node) booleanremoveProcessingInstruction(String target) Removes the processing instruction for the given target if it existsvoidsetAttributes(Attributes attributes, NamespaceStack namespaceStack, boolean noNamespaceAttributes) This method provides a more optimal way of setting all the attributes on an Element particularly for use inSAXReader.voidsetAttributeValue(String name, String value) Deprecated.As of version 0.5.voidsetAttributeValue(QName qName, String value) Deprecated.As of version 0.5.voidSets the data value of this element if this element supports data binding or callsNode.setText(String)if it doesn'tvoidSets the text data of this node or this method will throw anUnsupportedOperationExceptionif it is read-only.voidsetNamespace(Namespace namespace) voidSets the text data of this node or this method will throw anUnsupportedOperationExceptionif it is read-only.toString()voidwritewrites this node as the default XML notation for this node.Methods inherited from class AbstractBranch
addElement, addElement, addElement, appendContent, content, contentList, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getText, getTextTrim, hasContent, invalidNodeTypeAddException, isReadOnly, setProcessingInstructionsMethods inherited from class AbstractNode
asXPathResult, clone, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getDocument, getNodeTypeName, getParent, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, supportsParent, valueOfMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Branch
addElement, addElement, appendContent, clearContent, content, elementByID, setContent, setProcessingInstructionsMethods inherited from interface Element
getQName, getText, getTextTrim, setAttributes, setQNameMethods inherited from interface Node
asXPathResult, clone, createXPath, detach, getDocument, getNodeTypeName, getParent, getPath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setParent, supportsParent, valueOf
-
Field Details
-
VERBOSE_TOSTRING
protected static final boolean VERBOSE_TOSTRING- See Also:
-
USE_STRINGVALUE_SEPARATOR
protected static final boolean USE_STRINGVALUE_SEPARATOR- See Also:
-
-
Constructor Details
-
AbstractElement
public AbstractElement()
-
-
Method Details
-
getNodeType
public short getNodeType()Description copied from interface:NodeReturns the code according to the type of node. This makes processing nodes polymorphically much easier as the switch statement can be used instead of multiple if (instanceof) statements.- Specified by:
getNodeTypein interfaceNode- Overrides:
getNodeTypein classAbstractNode- Returns:
- a W3C DOM complient code for the node type such as ELEMENT_NODE or ATTRIBUTE_NODE
-
isRootElement
public boolean isRootElement()Description copied from interface:ElementDOCUMENT ME!- Specified by:
isRootElementin interfaceElement- Returns:
- true if this element is the root element of a document and this element supports the parent relationship else false.
-
setName
Description copied from interface:NodeSets the text data of this node or this method will throw an
UnsupportedOperationExceptionif it is read-only.- Specified by:
setNamein interfaceNode- Overrides:
setNamein classAbstractNode- Parameters:
name- is the new name of this node
-
setNamespace
-
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!
-
getPath
Description copied from interface:NodeReturns the relative XPath expression which will return a node set containing the given node such as a/b/@c. No indexing will be used to restrict the path if multiple elements with the same name occur on the path.- Specified by:
getPathin interfaceNode- Parameters:
context- 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.- Returns:
- the XPath expression relative to the given context which will return a nodeset containing at least this node.
-
getUniquePath
Description copied from interface:NodeReturns the relative unique XPath expression from the given context which will return a nodeset of one node which is the current node. This method will use the XPath index operator to restrict the path if multiple elements with the same name occur on the path.
- Specified by:
getUniquePathin interfaceNode- Parameters:
context- 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.- Returns:
- the XPath expression relative to the given context which will return a nodeset containing just this node.
-
asXML
-
write
Description copied from interface:Nodewritewrites this node as the default XML notation for this node. If you wish to control the XML output (such as for pretty printing, changing the indentation policy etc.) then please useXMLWriteror its derivations.- Specified by:
writein interfaceNode- Overrides:
writein classAbstractNode- Parameters:
out- is theWriterto output the XML to- Throws:
IOException- DOCUMENT ME!
-
accept
-
toString
-
getNamespace
Description copied from interface:ElementReturns theNamespaceof this element if one exists otherwiseNamespace.NO_NAMESPACEis returned.- Specified by:
getNamespacein interfaceElement- Returns:
- the
Namespaceassociated with this element
-
getName
Description copied from interface:NodegetNamereturns 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.- Specified by:
getNamein interfaceNode- Overrides:
getNamein classAbstractNode- Returns:
- the XML name of this node
-
getNamespacePrefix
Description copied from interface:ElementReturns the namespace prefix of this element if one exists otherwise an emptyStringis returned.- Specified by:
getNamespacePrefixin interfaceElement- Returns:
- the prefix of the
Namespaceof this element or an emptyString
-
getNamespaceURI
Description copied from interface:ElementReturns the URI mapped to the namespace of this element if one exists otherwise an emptyStringis returned.- Specified by:
getNamespaceURIin interfaceElement- Returns:
- the URI for the
Namespaceof this element or an emptyString
-
getQualifiedName
Description copied from interface:ElementReturns the fully qualified name of this element. This will be the same as the value returned fromNode.getName()if this element has no namespace attached to this element or an expression of the formgetNamespacePrefix() + ":" + getName()
will be returned.- Specified by:
getQualifiedNamein interfaceElement- Returns:
- the fully qualified name of the element.
-
getData
Description copied from interface:ElementAccesses 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 asElement.getText() -
setData
Description copied from interface:ElementSets the data value of this element if this element supports data binding or callsNode.setText(String)if it doesn't -
node
-
indexOf
Description copied from interface:BranchReturns 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 classAbstractBranch- Parameters:
node- the content child node to find.- Returns:
- the index of the given node starting at 0 or -1 if the node is not a child node of this branch
-
nodeCount
public int nodeCount()Description copied from interface:BranchReturns the number ofNodeinstances that this branch contains.- Specified by:
nodeCountin interfaceBranch- Overrides:
nodeCountin classAbstractBranch- Returns:
- the number of nodes this branch contains
-
nodeIterator
Description copied from interface:BranchReturns an iterator through the content nodes of this branch- Specified by:
nodeIteratorin interfaceBranch- Overrides:
nodeIteratorin classAbstractBranch- Returns:
- an iterator through the content nodes of this branch
-
element
-
element
Description copied from interface:ElementReturns the first element for the given fully qualified name. -
element
-
elements
Description copied from interface:ElementReturns the elements contained in this element. If this element does not contain any elements then this method returns an empty list. 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. -
elements
Description copied from interface:ElementReturns the elements contained in this element with the given local name and any namespace. If no elements are found then this method returns an empty list. 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. -
elements
Description copied from interface:ElementReturns the elements contained in this element with the given fully qualified name. If no elements are found then this method returns an empty list. 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. -
elements
-
elementIterator
Description copied from interface:ElementReturns an iterator over all this elements child elements.- Specified by:
elementIteratorin interfaceElement- Returns:
- an iterator over the contained elements
-
elementIterator
Description copied from interface:ElementReturns an iterator over the elements contained in this element which match the given local name and any namespace.- Specified by:
elementIteratorin interfaceElement- Parameters:
name- DOCUMENT ME!- Returns:
- an iterator over the contained elements matching the given local name
-
elementIterator
Description copied from interface:ElementReturns an iterator over the elements contained in this element which match the given fully qualified name.- Specified by:
elementIteratorin interfaceElement- Parameters:
qName- is the fully qualified name to search for- Returns:
- an iterator over the contained elements matching the given fully qualified name
-
elementIterator
-
attributes
Description copied from interface:ElementReturns theAttributeinstances 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- Returns:
- the attributes that this element contains as a
List
-
attributeIterator
Description copied from interface:ElementDOCUMENT ME!- Specified by:
attributeIteratorin interfaceElement- Returns:
- an iterator over the attributes of this element
-
attribute
Description copied from interface:ElementReturns the attribute at the specified indexGets the -
attributeCount
public int attributeCount()Description copied from interface:ElementDOCUMENT ME!- Specified by:
attributeCountin interfaceElement- Returns:
- the number of attributes this element contains
-
attribute
Description copied from interface:ElementReturns the attribute with the given name -
attribute
-
attribute
-
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 inSAXReader.- Parameters:
attributes- DOCUMENT ME!namespaceStack- DOCUMENT ME!noNamespaceAttributes- DOCUMENT ME!
-
attributeValue
Description copied from interface:ElementThis 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.- Specified by:
attributeValuein interfaceElement- Parameters:
name- is the name of the attribute value to be returned- Returns:
- the value of the attribute, null if the attribute does not exist or the empty string
-
attributeValue
Description copied from interface:ElementThis 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.- Specified by:
attributeValuein interfaceElement- Parameters:
qName- is the fully qualified name- Returns:
- the value of the attribute, null if the attribute does not exist or the empty string
-
attributeValue
Description copied from interface:ElementThis 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.- Specified by:
attributeValuein interfaceElement- Parameters:
name- is the name of the attribute value to be returneddefaultValue- is the default value to be returned if the attribute has no value defined.- Returns:
- the value of the attribute or the defaultValue if the attribute has no value defined.
-
attributeValue
Description copied from interface:ElementThis returns the attribute value for the attribute with the given fully qualified name or the default value if there is no such attribute value.- Specified by:
attributeValuein interfaceElement- Parameters:
qName- is the fully qualified namedefaultValue- is the default value to be returned if the attribute has no value defined.- Returns:
- the value of the attribute or the defaultValue if the attribute has no value defined.
-
setAttributeValue
Deprecated.As of version 0.5. Please useaddAttribute(String, String)instead. WILL BE REMOVED IN dom4j-1.6 !!DOCUMENT ME!- Specified by:
setAttributeValuein interfaceElement- Parameters:
name- DOCUMENT ME!value- DOCUMENT ME!
-
setAttributeValue
Deprecated.As of version 0.5. Please useaddAttribute(String, String)instead. WILL BE REMOVED IN dom4j-1.6 !!DOCUMENT ME!- Specified by:
setAttributeValuein interfaceElement- Parameters:
qName- DOCUMENT ME!value- DOCUMENT ME!
-
add
Description copied from interface:ElementAdds the givenAttributeto 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. -
remove
-
processingInstructions
Description copied from interface: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.- Specified by:
processingInstructionsin interfaceBranch- Returns:
- a backed list of the processing instructions
-
processingInstructions
Description copied from interface: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.- Specified by:
processingInstructionsin interfaceBranch- Parameters:
target- DOCUMENT ME!- Returns:
- a backed list of the processing instructions
-
processingInstruction
Description copied from interface:BranchDOCUMENT ME!- Specified by:
processingInstructionin interfaceBranch- Parameters:
target- DOCUMENT ME!- Returns:
- the processing instruction for the given target
-
removeProcessingInstruction
Description copied from interface:BranchRemoves the processing instruction for the given target if it exists- Specified by:
removeProcessingInstructionin interfaceBranch- Parameters:
target- DOCUMENT ME!- Returns:
- true if a processing instruction was removed else false
-
getXPathResult
Description copied from interface:ElementReturns a node at the given index suitable for an XPath result set. This means the resulting Node will either be null or it will support the parent relationship.- Specified by:
getXPathResultin interfaceElement- Parameters:
index- DOCUMENT ME!- Returns:
- the Node for the given index which will support the parent relationship or null if there is not a node at the given index.
-
addAttribute
Description copied from interface:ElementAdds the attribute value of the given local name. If an attribute already exists for the given name it will be replaced. 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 given name.- Specified by:
addAttributein interfaceElement- Parameters:
name- is the name of the attribute whose value is to be added or updatedvalue- is the attribute's value- Returns:
- this
Elementinstance.
-
addAttribute
Description copied from interface:ElementAdds the attribute value of the given fully qualified name. If an attribute already exists for the given name it will be replaced. 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 given name.- Specified by:
addAttributein interfaceElement- Parameters:
qName- is the fully qualified name of the attribute whose value is to be added or updatedvalue- is the attribute's value- Returns:
- this
Elementinstance.
-
addCDATA
-
addComment
Description copied from interface:ElementAdds a newCommentnode with the given text to this element.- Specified by:
addCommentin interfaceElement- Parameters:
comment- is the text for theCommentnode.- Returns:
- this
Elementinstance.
-
addElement
Description copied from interface:BranchAdds a newElementnode with the given name to this branch and returns a reference to the new node.- Specified by:
addElementin interfaceBranch- Overrides:
addElementin classAbstractBranch- Parameters:
name- is the name for theElementnode.- Returns:
- the newly added
Elementnode.
-
addEntity
Description copied from interface:ElementAdds a newEntitynode with the given name and text to this element and returns a reference to the new node. -
addNamespace
Description copied from interface:ElementAdds a namespace to this element for use by its child content- Specified by:
addNamespacein interfaceElement- Parameters:
prefix- is the prefix to use, which should not be null or blankuri- is the namespace URI- Returns:
- this
Elementinstance.
-
addProcessingInstruction
Description copied from interface:ElementAdds a processing instruction for the given target- Specified by:
addProcessingInstructionin interfaceElement- Parameters:
target- is the target of the processing instructiondata- is the textual data (key/value pairs) of the processing instruction- Returns:
- this
Elementinstance.
-
addProcessingInstruction
Description copied from interface:ElementAdds a processing instruction for the given target- Specified by:
addProcessingInstructionin interfaceElement- Parameters:
target- is the target of the processing instructiondata- is a Map of the key / value pairs of the processing instruction- Returns:
- this
Elementinstance.
-
addText
-
add
Description copied from interface:BranchAdds the givenNodeor throwsIllegalAddExceptionif the given node is not of a valid type. This is a polymorphic method which will call the typesafe method for the node type such as add(Element) or add(Comment).- Specified by:
addin interfaceBranch- Overrides:
addin classAbstractBranch- Parameters:
node- is the given node to add
-
remove
Description copied from interface:BranchRemoves the givenNodeif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead. This is a polymorphic method which will call the typesafe method for the node type such as remove(Element) or remove(Comment).- Specified by:
removein interfaceBranch- Overrides:
removein classAbstractBranch- Parameters:
node- is the given node to be removed- Returns:
- true if the node was removed
-
add
-
add
Description copied from interface:BranchAdds the givenCommentto this branch. If the given node already has a parent defined then anIllegalAddExceptionwill be thrown.- Specified by:
addin interfaceBranch- Overrides:
addin classAbstractBranch- Parameters:
comment- is the comment to be added
-
add
Description copied from interface:BranchAdds the givenElementto this branch. If the given node already has a parent defined then anIllegalAddExceptionwill be thrown.- Specified by:
addin interfaceBranch- Overrides:
addin classAbstractBranch- Parameters:
element- is the element to be added
-
add
-
add
Description copied from interface:ElementAdds the givenNamespaceto this element. If the given node already has a parent defined then anIllegalAddExceptionwill be thrown. -
add
Description copied from interface:BranchAdds the givenProcessingInstructionto this branch. If the given node already has a parent defined then anIllegalAddExceptionwill be thrown.- Specified by:
addin interfaceBranch- Overrides:
addin classAbstractBranch- Parameters:
pi- is the processing instruction to be added
-
add
-
remove
Description copied from interface:ElementRemoves the givenCDATAif the node is an immediate child of this element. If the given node is not an immediate child of this element then theNode.detach()method should be used instead. -
remove
Description copied from interface:BranchRemoves the givenCommentif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead.- Specified by:
removein interfaceBranch- Overrides:
removein classAbstractBranch- Parameters:
comment- is the comment to be removed- Returns:
- true if the comment was removed
-
remove
Description copied from interface:BranchRemoves the givenElementif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead.- Specified by:
removein interfaceBranch- Overrides:
removein classAbstractBranch- Parameters:
element- is the element to be removed- Returns:
- true if the element was removed
-
remove
Description copied from interface:ElementRemoves the givenEntityif the node is an immediate child of this element. If the given node is not an immediate child of this element then theNode.detach()method should be used instead. -
remove
Description copied from interface:ElementRemoves the givenNamespaceif the node is an immediate child of this element. If the given node is not an immediate child of this element then theNode.detach()method should be used instead. -
remove
Description copied from interface:BranchRemoves the givenProcessingInstructionif the node is an immediate child of this branch. If the given node is not an immediate child of this branch then theNode.detach()method should be used instead.- Specified by:
removein interfaceBranch- Overrides:
removein classAbstractBranch- Parameters:
pi- is the processing instruction to be removed- Returns:
- true if the processing instruction was removed
-
remove
Description copied from interface:ElementRemoves the givenTextif the node is an immediate child of this element. If the given node is not an immediate child of this element then theNode.detach()method should be used instead. -
hasMixedContent
public boolean hasMixedContent()Description copied from interface:ElementReturns true if thisElementhas mixed content. Mixed content means that an element contains both textual data and child elements.- Specified by:
hasMixedContentin interfaceElement- Returns:
- true if this element contains mixed content.
-
isTextOnly
public boolean isTextOnly()Description copied from interface:ElementReturns true if thisElementhas text only content.- Specified by:
isTextOnlyin interfaceElement- Returns:
- true if this element is empty or only contains text content.
-
setText
Description copied from interface:NodeSets the text data of this node or this method will throw an
UnsupportedOperationExceptionif it is read-only.- Specified by:
setTextin interfaceNode- Overrides:
setTextin classAbstractNode- Parameters:
text- is the new textual value of this node
-
getStringValue
Description copied from interface:NodeReturns the XPath string-value of this node. The behaviour of this method is defined in the XPath specification .- Specified by:
getStringValuein interfaceElement- Specified by:
getStringValuein interfaceNode- Overrides:
getStringValuein classAbstractNode- Returns:
- the text from all the child Text and Element nodes appended together.
-
normalize
public void normalize()Puts allTextnodes in the full depth of the sub-tree underneath thisNode, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separatesTextnodes, i.e., there are neither adjacentTextnodes nor emptyTextnodes. 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 containsCDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate betweenTextnodes andCDATASectionnodes. -
elementText
- Specified by:
elementTextin interfaceElement
-
elementText
- Specified by:
elementTextin interfaceElement
-
elementTextTrim
- Specified by:
elementTextTrimin interfaceElement
-
elementTextTrim
- Specified by:
elementTextTrimin interfaceElement
-
appendAttributes
Description copied from interface:ElementAppends the attributes of the given element to me. This method behaves like theCollection.addAll(java.util.Collection)method.- Specified by:
appendAttributesin interfaceElement- Parameters:
element- is the element whose attributes will be added to me.
-
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.
- Specified by:
createCopyin interfaceElement- Returns:
- the clone of this element
-
createCopy
Description copied from interface:ElementCreates 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.- Specified by:
createCopyin interfaceElement- Parameters:
name- DOCUMENT ME!- Returns:
- a new deep copy Element
-
createCopy
Description copied from interface:ElementCreates a deep copy of this element with the given fully qualified name. The new element is detached from its parent, and getParent() on the clone will return null.- Specified by:
createCopyin interfaceElement- Parameters:
qName- DOCUMENT ME!- Returns:
- a new deep copy Element
-
getQName
Description copied from interface:ElementReturns theQNamefor 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. -
getNamespaceForPrefix
Description copied from interface:ElementReturns theNamespacewhich is mapped to the given prefix or null if it could not be found.- Specified by:
getNamespaceForPrefixin interfaceElement- Parameters:
prefix- DOCUMENT ME!- Returns:
- the
Namespaceassociated with the given prefix
-
getNamespaceForURI
Description copied from interface:ElementReturns theNamespacewhich 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- Parameters:
uri- DOCUMENT ME!- Returns:
- the
Namespaceassociated with the given URI
-
getNamespacesForURI
Description copied from interface:ElementReturns the all namespaces which are mapped to the given URI or an empty list if no such namespaces could be found.- Specified by:
getNamespacesForURIin interfaceElement- Parameters:
uri- DOCUMENT ME!- Returns:
- the namespaces associated with the given URI
-
declaredNamespaces
Description copied from interface: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.- Specified by:
declaredNamespacesin interfaceElement- Returns:
- a list of namespaces declared for this element.
-
additionalNamespaces
Description copied from interface:ElementReturns any additional namespaces declarations for this element other than namespace returned via theElement.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- Returns:
- a list of any additional namespace declarations.
-
additionalNamespaces
-
ensureAttributesCapacity
public void ensureAttributesCapacity(int minCapacity) Ensures that the list of attributes has the given size- Parameters:
minCapacity- DOCUMENT ME!
-
createElement
-
createElement
-
addNode
- Specified by:
addNodein classAbstractBranch
-
addNode
- Specified by:
addNodein classAbstractBranch
-
addNewNode
Like addNode() but does not require a parent check- Parameters:
node- DOCUMENT ME!
-
addNewNode
-
removeNode
- Specified by:
removeNodein classAbstractBranch
-
childAdded
Called when a new child node is added to create any parent relationships- Specified by:
childAddedin classAbstractBranch- Parameters:
node- DOCUMENT ME!
-
childRemoved
Description copied from class:AbstractBranchCalled when a child node has been removed to allow any parent relationships to be deleted or events to be fired.- Specified by:
childRemovedin classAbstractBranch- Parameters:
node- DOCUMENT ME!
-
attributeList
-
attributeList
-
getDocumentFactory
- Overrides:
getDocumentFactoryin classAbstractNode
-
createAttributeList
-
createAttributeList
-
createSingleIterator
-