public class Node extends JavaScriptObject
Modifier and Type | Field and Description |
---|---|
static short |
DOCUMENT_NODE
The node is a
Document . |
static short |
ELEMENT_NODE
The node is an
Element . |
static short |
TEXT_NODE
The node is a
Text node. |
Modifier | Constructor and Description |
---|---|
protected |
Node() |
Modifier and Type | Method and Description |
---|---|
<T extends Node> |
appendChild(T newChild)
Adds the node newChild to the end of the list of children of this node.
|
static Node |
as(JavaScriptObject o)
Assert that the given
JavaScriptObject is a DOM node and
automatically typecast it. |
Node |
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy
constructor for nodes.
|
Node |
getChild(int index)
Gets the child node at the given index.
|
int |
getChildCount()
Gets the number of child nodes contained within this node.
|
NodeList<Node> |
getChildNodes()
A NodeList that contains all children of this node.
|
Node |
getFirstChild()
The first child of this node.
|
Node |
getLastChild()
The last child of this node.
|
Node |
getNextSibling()
The node immediately following this node.
|
java.lang.String |
getNodeName()
The name of this node, depending on its type; see the table above.
|
short |
getNodeType()
A code representing the type of the underlying object, as defined above.
|
java.lang.String |
getNodeValue()
The value of this node, depending on its type; see the table above.
|
Document |
getOwnerDocument()
The Document object associated with this node.
|
Element |
getParentElement()
Gets the parent element of this node.
|
Node |
getParentNode()
The parent of this node.
|
Node |
getPreviousSibling()
The node immediately preceding this node.
|
boolean |
hasChildNodes()
Returns whether this node has any children.
|
boolean |
hasParentElement()
Determines whether this node has a parent element.
|
Node |
insertAfter(Node newChild,
Node refChild)
Inserts the node newChild after the existing child node refChild.
|
Node |
insertBefore(Node newChild,
Node refChild)
Inserts the node newChild before the existing child node refChild.
|
Node |
insertFirst(Node child)
Inserts the given child as the first child of this node.
|
static boolean |
is(JavaScriptObject o)
Determines whether the given
JavaScriptObject is a DOM node. |
boolean |
isOrHasChild(Node child)
Determine whether a node is equal to, or the child of, this node.
|
Node |
removeAllChildren()
Remove all children of the node.
|
Node |
removeChild(Node oldChild)
Removes the child node indicated by oldChild from the list of children, and
returns it.
|
void |
removeFromParent()
Removes this node from its parent node if it is attached to one.
|
Node |
replaceChild(Node newChild,
Node oldChild)
Replaces the child node oldChild with newChild in the list of children, and
returns the oldChild node.
|
void |
setNodeValue(java.lang.String nodeValue)
The value of this node, depending on its type; see the table above.
|
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
public static final short ELEMENT_NODE
Element
.public static final short TEXT_NODE
Text
node.public static final short DOCUMENT_NODE
Document
.public static Node as(JavaScriptObject o)
JavaScriptObject
is a DOM node and
automatically typecast it.public static boolean is(JavaScriptObject o)
JavaScriptObject
is a DOM node. A
null
object will cause this method to return
false
.
The try catch is needed for the firefox permission error:
"Permission denied to access property 'nodeType'"public final <T extends Node> T appendChild(T newChild)
newChild
- The node to addpublic final Node cloneNode(boolean deep)
deep
- If true, recursively clone the subtree under the specified
node; if false, clone only the node itself (and its attributes, if
it is an Element
)public final Node getChild(int index)
index
- the index of the node to be retrievedpublic final int getChildCount()
public final NodeList<Node> getChildNodes()
public final Node getFirstChild()
public final Node getLastChild()
public final Node getNextSibling()
public final java.lang.String getNodeName()
public final short getNodeType()
public final java.lang.String getNodeValue()
public final Document getOwnerDocument()
Document
object used to create new nodes.public final Element getParentElement()
null
if none existspublic final Node getParentNode()
public final Node getPreviousSibling()
public final boolean hasChildNodes()
public final boolean hasParentElement()
public final Node insertAfter(Node newChild, Node refChild)
null
, insert newChild at the end of the list of children.newChild
- The node to insertrefChild
- The reference node (that is, the node after which the new
node must be inserted), or null
public final Node insertBefore(Node newChild, Node refChild)
null
, insert newChild at the end of the list of children.newChild
- The node to insertrefChild
- The reference node (that is, the node before which the new
node must be inserted), or null
public final Node insertFirst(Node child)
child
- the child to be insertedpublic final boolean isOrHasChild(Node child)
child
- the potential child elementtrue
if the relationship holdspublic final Node removeChild(Node oldChild)
oldChild
- The node being removedpublic final Node removeAllChildren()
public final void removeFromParent()
public final Node replaceChild(Node newChild, Node oldChild)
newChild
- The new node to put in the child listoldChild
- The node being replaced in the listpublic final void setNodeValue(java.lang.String nodeValue)