public class ElementImpl extends ParentNSNodeImpl implements Element
Element inherits the generic Node
interface and adds support for retrieving and setting attributes either as
nodes or as strings.
Notes:
Node.ELEMENT_NODE
To speed up implementation, all attributes are implemented as double-linked list implemented using _parent, _nextNode and _prevNode. This support is provided to through appendAttr and removeAttr methods.
Element,
Attr,
NamedNodeMap,
AttrImplATTLIST_DECL_NODE, ELEMENT_DECL_NODE, PARAM_ENTITY_NODEATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE| Constructor and Description |
|---|
ElementImpl(DocumentImpl owner,
String namespaceURI,
String qualifiedName)
Constructor requires only owner document, optional namespace URI and
qualified name.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone() |
protected void |
cloneInto(NodeImpl into,
boolean deep)
This clone method is called after a new node has been constructed to
copy the contents of this node into the new one.
|
Node |
cloneNode(boolean deep) |
short |
compareDocumentPosition(Node other) |
boolean |
equals(Object other)
Returns true if this node and other are identical by content but
not context.
|
String |
getAttribute(String name) |
Attr |
getAttributeNode(String name) |
Attr |
getAttributeNodeNS(String namespaceURI,
String localName) |
String |
getAttributeNS(String namespaceURI,
String localName) |
NamedNodeMap |
getAttributes()
Return attributes of node.
|
String |
getBaseURI() |
NodeList |
getElementsByTagName(String tagName)
Returns a list of elements extracted based on their tag name (or all of
them if the tag name is "*").
|
NodeList |
getElementsByTagNameNS(String namespaceURI,
String localName) |
Object |
getFeature(String feature,
String version) |
short |
getNodeType()
Abstract method must be implemented by each node class.
|
TypeInfo |
getSchemaTypeInfo() |
String |
getTagName()
Returns the name of the tag, same as calling
NodeImpl.getNodeName(). |
String |
getTextContent() |
Object |
getUserData(String key) |
boolean |
hasAttribute(String name)
Introduced in DOM Level 2.
|
boolean |
hasAttributeNS(String namespaceURI,
String localName)
Introduced in DOM Level 2.
|
boolean |
hasAttributes() |
boolean |
isDefaultNamespace(String namespaceURI) |
boolean |
isEqualNode(Node arg) |
boolean |
isSameNode(Node other) |
boolean |
isSupported(String feature,
String version) |
String |
lookupNamespaceURI(String prefix) |
String |
lookupPrefix(String namespaceURI) |
void |
normalize() |
void |
removeAttribute(String name) |
Attr |
removeAttributeNode(Attr oldAttr) |
void |
removeAttributeNS(String namespaceURI,
String localName) |
void |
setAttribute(String name,
String value) |
Attr |
setAttributeNode(Attr newAttr) |
Attr |
setAttributeNodeNS(Attr newAttr) |
void |
setAttributeNS(String namespaceURI,
String localName,
String value) |
void |
setIdAttribute(String name,
boolean isId) |
void |
setIdAttributeNode(Attr idAttr,
boolean isId) |
void |
setIdAttributeNS(String namespaceURI,
String localName,
boolean isId) |
void |
setNodeValue(String value)
Changes the value of the node.
|
void |
setTextContent(String textContent) |
Object |
setUserData(String key,
Object data,
UserDataHandler handler) |
String |
toString() |
getLocalName, getNamespaceURI, getPrefix, setPrefixappendChild, castNewChild, castOldChild, createNodeIterator, getChildNodes, getFirstChild, getLastChild, hasChildNodes, insertBefore, removeChild, removeInnerIterator, replaceChildgetNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, isReadOnly, makeReadOnly, setOwnerDocument, supportsfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendChild, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, removeChild, replaceChild, setPrefixpublic ElementImpl(DocumentImpl owner, String namespaceURI, String qualifiedName)
owner - Owner document of this elementnamespaceURI - The namespace URI, or nullqualifiedName - The qualified name of this elementpublic final short getNodeType()
NodeImplgetNodeType in interface NodegetNodeType in class NodeImplNode.getNodeType()public final String getTagName()
NodeImpl.getNodeName().
In XML documents, the return value preserves case. In HTML documents,
the return value is always upper case regardless of the original value.getTagName in interface Elementpublic final void setNodeValue(String value)
NodeImplElement Not supported Attr Supported Text Supported CDATASection Supported EntityReference Not supported Entity Not supported ProcessingInstruction Supported Comment Supported Document Not supported DocumentType Not supported DocumentFragment Not supported Notation Not supportedFor most node types, if the value is set to null,
NodeImpl.getNodeValue()
will return an empty string instead.setNodeValue in interface NodesetNodeValue in class NodeImplvalue - New value of nodepublic NodeList getElementsByTagName(String tagName)
getElementsByTagName in interface ElementtagName - The element tag name to look for or "*" for all elementspublic NodeList getElementsByTagNameNS(String namespaceURI, String localName)
getElementsByTagNameNS in interface Elementpublic final NamedNodeMap getAttributes()
NodeImplElement, in which case the returned NamedNodeMap will provide
access to all the element's
attributes.getAttributes in interface NodegetAttributes in class NodeImplpublic String getAttribute(String name)
getAttribute in interface Elementpublic String getAttributeNS(String namespaceURI, String localName)
getAttributeNS in interface Elementpublic final void setAttribute(String name, String value)
setAttribute in interface Elementpublic final void setAttributeNS(String namespaceURI, String localName, String value) throws DOMException
setAttributeNS in interface ElementDOMExceptionpublic final void removeAttributeNS(String namespaceURI, String localName)
removeAttributeNS in interface Elementpublic final void removeAttribute(String name)
removeAttribute in interface Elementpublic Attr getAttributeNode(String name)
getAttributeNode in interface Elementpublic Attr getAttributeNodeNS(String namespaceURI, String localName)
getAttributeNodeNS in interface Elementpublic final Attr setAttributeNode(Attr newAttr) throws DOMException
setAttributeNode in interface ElementDOMExceptionpublic final Attr setAttributeNodeNS(Attr newAttr) throws DOMException
setAttributeNodeNS in interface ElementDOMExceptionpublic final Attr removeAttributeNode(Attr oldAttr)
removeAttributeNode in interface Elementpublic final void normalize()
normalize in interface Nodenormalize in class ParentNodeImplpublic boolean equals(Object other)
NodeImplNodeImpl.equals(java.lang.Object) on each pair
Note that for large document roots, the equality operation can be very expensive.
equals in class ParentNSNodeImplother - The other node to test for equalityprotected void cloneInto(NodeImpl into, boolean deep)
NodeImplNodeImpl.equals(java.lang.Object)).
into must be a valid node of the exact same class as this one. deep is true if deep cloning (includes all children nodes) is to be performed. If deep is false, the clone might not pass the equality test.
Derived classes override and call this method to add per-class variable
copying. This method is called by Node.cloneNode(boolean) and the default
Object.clone() method.
Contents cloning duplicates the node's name and value, and its children. It does not duplicate it's context, that is, the node's parent or sibling. Initially a clone node has no parents or siblings. However, the node does belong to the same document, since all nodes must belong to some document. The cloned node is never read-only.
cloneInto in class ParentNSNodeImplinto - A node into which to duplicate this onedeep - True if deep cloning is requiredpublic boolean hasAttribute(String name)
hasAttribute in interface Elementpublic boolean hasAttributeNS(String namespaceURI, String localName)
hasAttributeNS in interface Elementpublic TypeInfo getSchemaTypeInfo()
getSchemaTypeInfo in interface Elementpublic void setIdAttribute(String name, boolean isId) throws DOMException
setIdAttribute in interface ElementDOMExceptionpublic void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException
setIdAttributeNS in interface ElementDOMExceptionpublic void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException
setIdAttributeNode in interface ElementDOMExceptionpublic short compareDocumentPosition(Node other) throws DOMException
compareDocumentPosition in interface NodeDOMExceptionpublic String getBaseURI()
getBaseURI in interface Nodepublic Object getFeature(String feature, String version)
getFeature in interface Nodepublic String getTextContent() throws DOMException
getTextContent in interface NodeDOMExceptionpublic Object getUserData(String key)
getUserData in interface Nodepublic boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace in interface Nodepublic boolean isEqualNode(Node arg)
isEqualNode in interface Nodepublic boolean isSameNode(Node other)
isSameNode in interface Nodepublic String lookupNamespaceURI(String prefix)
lookupNamespaceURI in interface Nodepublic String lookupPrefix(String namespaceURI)
lookupPrefix in interface Nodepublic void setTextContent(String textContent) throws DOMException
setTextContent in interface NodeDOMExceptionpublic Object setUserData(String key, Object data, UserDataHandler handler)
setUserData in interface Nodepublic boolean hasAttributes()
hasAttributes in interface Nodepublic boolean isSupported(String feature, String version)
isSupported in interface NodePhantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.