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
,
AttrImpl
ATTLIST_DECL_NODE, ELEMENT_DECL_NODE, PARAM_ENTITY_NODE
ATTRIBUTE_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, setPrefix
appendChild, castNewChild, castOldChild, createNodeIterator, getChildNodes, getFirstChild, getLastChild, hasChildNodes, insertBefore, removeChild, removeInnerIterator, replaceChild
getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, isReadOnly, makeReadOnly, setOwnerDocument, supports
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
appendChild, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, removeChild, replaceChild, setPrefix
public 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()
NodeImpl
getNodeType
in interface Node
getNodeType
in class NodeImpl
Node.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 Element
public final void setNodeValue(String value)
NodeImpl
Element 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 Node
setNodeValue
in class NodeImpl
value
- New value of nodepublic NodeList getElementsByTagName(String tagName)
getElementsByTagName
in interface Element
tagName
- The element tag name to look for or "*" for all elementspublic NodeList getElementsByTagNameNS(String namespaceURI, String localName)
getElementsByTagNameNS
in interface Element
public final NamedNodeMap getAttributes()
NodeImpl
Element
, in which case the returned NamedNodeMap
will provide
access to all the element's
attributes.getAttributes
in interface Node
getAttributes
in class NodeImpl
public String getAttribute(String name)
getAttribute
in interface Element
public String getAttributeNS(String namespaceURI, String localName)
getAttributeNS
in interface Element
public final void setAttribute(String name, String value)
setAttribute
in interface Element
public final void setAttributeNS(String namespaceURI, String localName, String value) throws DOMException
setAttributeNS
in interface Element
DOMException
public final void removeAttributeNS(String namespaceURI, String localName)
removeAttributeNS
in interface Element
public final void removeAttribute(String name)
removeAttribute
in interface Element
public Attr getAttributeNode(String name)
getAttributeNode
in interface Element
public Attr getAttributeNodeNS(String namespaceURI, String localName)
getAttributeNodeNS
in interface Element
public final Attr setAttributeNode(Attr newAttr) throws DOMException
setAttributeNode
in interface Element
DOMException
public final Attr setAttributeNodeNS(Attr newAttr) throws DOMException
setAttributeNodeNS
in interface Element
DOMException
public final Attr removeAttributeNode(Attr oldAttr)
removeAttributeNode
in interface Element
public final void normalize()
normalize
in interface Node
normalize
in class ParentNodeImpl
public boolean equals(Object other)
NodeImpl
NodeImpl.equals(java.lang.Object)
on each pair
Note that for large document roots, the equality operation can be very expensive.
equals
in class ParentNSNodeImpl
other
- The other node to test for equalityprotected void cloneInto(NodeImpl into, boolean deep)
NodeImpl
NodeImpl.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 ParentNSNodeImpl
into
- A node into which to duplicate this onedeep
- True if deep cloning is requiredpublic boolean hasAttribute(String name)
hasAttribute
in interface Element
public boolean hasAttributeNS(String namespaceURI, String localName)
hasAttributeNS
in interface Element
public TypeInfo getSchemaTypeInfo()
getSchemaTypeInfo
in interface Element
public void setIdAttribute(String name, boolean isId) throws DOMException
setIdAttribute
in interface Element
DOMException
public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException
setIdAttributeNS
in interface Element
DOMException
public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException
setIdAttributeNode
in interface Element
DOMException
public short compareDocumentPosition(Node other) throws DOMException
compareDocumentPosition
in interface Node
DOMException
public String getBaseURI()
getBaseURI
in interface Node
public Object getFeature(String feature, String version)
getFeature
in interface Node
public String getTextContent() throws DOMException
getTextContent
in interface Node
DOMException
public Object getUserData(String key)
getUserData
in interface Node
public boolean isDefaultNamespace(String namespaceURI)
isDefaultNamespace
in interface Node
public boolean isEqualNode(Node arg)
isEqualNode
in interface Node
public boolean isSameNode(Node other)
isSameNode
in interface Node
public String lookupNamespaceURI(String prefix)
lookupNamespaceURI
in interface Node
public String lookupPrefix(String namespaceURI)
lookupPrefix
in interface Node
public void setTextContent(String textContent) throws DOMException
setTextContent
in interface Node
DOMException
public Object setUserData(String key, Object data, UserDataHandler handler)
setUserData
in interface Node
public boolean hasAttributes()
hasAttributes
in interface Node
public boolean isSupported(String feature, String version)
isSupported
in interface Node
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.