Package org.pepstock.charba.client.dom
Class BaseNode
- java.lang.Object
-
- org.pepstock.charba.client.dom.BaseEventTarget
-
- org.pepstock.charba.client.dom.BaseNode
-
- Direct Known Subclasses:
BaseAttribute,BaseDocument,BaseElement,TextNode
@JsType(isNative=true, name="Node", namespace="<global>") public abstract class BaseNode extends BaseEventTargetA object from which various types of DOM objects inherit, allowing those types to be treated similarly.- Author:
- Andrea "Stock" Stocchero
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.pepstock.charba.client.dom.BaseEventTarget
BaseEventTarget.EventListenerCallback
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseNode()To avoid any instantiation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BaseNodeappendChild(BaseNode newChild)Adds a node to the end of the list of children of a specified parent node.
If the given child is a reference to an existing node in the document, it moves it from its current position to the new position (there is no requirement to remove the node from its parent node before appending it to some other node).BaseNodecloneNode(boolean deep)Clone the node, and optionally, all of its contents.NodeList<BaseNode>getChildNodes()Returns a list containing all the children of this node.BaseNodegetFirstChild()Returns a node representing the first direct child node of the node, ornullif the node has no child.BaseNodegetLastChild()Returns a node representing the last direct child node of the node, ornullif the node has no child.BaseNodegetNextSibling()Returns a node representing the next node in the tree, ornullif there isn't such node.StringgetNodeName()Returns a string containing the name of the node.
The structure of the name will differ with the node type.NodeTypegetNodeType()Returns the type of the node.StringgetNodeValue()Returns the value of the current node.BaseDocumentgetOwnerDocument()Returns the document that this node belongs to.
If the node is itself a document, returnsnull.BaseElementgetParentElement()Returns an element that is the parent of this node.
If the node has no parent, or if that parent is not an element, returnsnull.BaseNodegetParentNode()Returns a node that is the parent of this node.
If there is no such node, returnsnull.BaseNodegetPreviousSibling()Returns a node representing the previous node in the tree, ornullif there isn't such node.StringgetTextContent()Returns the textual content of an element and all its descendants.booleanhasChildNodes()Returns a boolean indicating whether or not the element has any child nodes.BaseNodeinsertBefore(BaseNode newChild, BaseNode refChild)Inserts a node before the reference node as a child of a specified parent node.voidremoveAllChildren()Remove all children of the node.BaseNoderemoveChild(BaseNode oldChild)Removes a child node from the current element, which must be a child of the current node.voidsetNodeValue(String nodeValue)Sets the value of the current node.voidsetTextContent(String textContent)Sets the textual content of an element and all its descendants.-
Methods inherited from class org.pepstock.charba.client.dom.BaseEventTarget
addEventListener, removeEventListener
-
-
-
-
Method Detail
-
getChildNodes
@JsProperty public final NodeList<BaseNode> getChildNodes()
Returns a list containing all the children of this node.- Returns:
- a list containing all the children of this node
-
getFirstChild
@JsProperty public final BaseNode getFirstChild()
Returns a node representing the first direct child node of the node, ornullif the node has no child.- Returns:
- a node representing the first direct child node of the node, or
nullif the node has no child
-
getLastChild
@JsProperty public final BaseNode getLastChild()
Returns a node representing the last direct child node of the node, ornullif the node has no child.- Returns:
- a node representing the last direct child node of the node, or
nullif the node has no child
-
getNextSibling
@JsProperty public final BaseNode getNextSibling()
Returns a node representing the next node in the tree, ornullif there isn't such node.- Returns:
- a node representing the next node in the tree, or
nullif there isn't such node
-
getNodeName
@JsProperty public final String getNodeName()
Returns a string containing the name of the node.
The structure of the name will differ with the node type.- Returns:
- a string containing the name of the node
-
getNodeType
@JsOverlay public final NodeType getNodeType()
Returns the type of the node.- Returns:
- the type of the node
-
getNodeValue
@JsProperty public final String getNodeValue()
Returns the value of the current node.- Returns:
- the value of the current node
-
setNodeValue
@JsProperty public final void setNodeValue(String nodeValue)
Sets the value of the current node.- Parameters:
nodeValue- the value of the current node
-
getOwnerDocument
@JsProperty public final BaseDocument getOwnerDocument()
Returns the document that this node belongs to.
If the node is itself a document, returnsnull.- Returns:
- the document that this node belongs to
-
getParentNode
@JsProperty public final BaseNode getParentNode()
Returns a node that is the parent of this node.
If there is no such node, returnsnull.- Returns:
- a node that is the parent of this node
-
getParentElement
@JsProperty public BaseElement getParentElement()
Returns an element that is the parent of this node.
If the node has no parent, or if that parent is not an element, returnsnull.- Returns:
- an element that is the parent of this node
-
getPreviousSibling
@JsProperty public final BaseNode getPreviousSibling()
Returns a node representing the previous node in the tree, ornullif there isn't such node.- Returns:
- a node representing the previous node in the tree, or
nullif there isn't such node
-
getTextContent
@JsProperty public final String getTextContent()
Returns the textual content of an element and all its descendants.- Returns:
- the textual content of an element and all its descendants
-
setTextContent
@JsProperty public final void setTextContent(String textContent)
Sets the textual content of an element and all its descendants.- Parameters:
textContent- the textual content of an element and all its descendants
-
appendChild
@JsMethod public final BaseNode appendChild(BaseNode newChild)
Adds a node to the end of the list of children of a specified parent node.
If the given child is a reference to an existing node in the document, it moves it from its current position to the new position (there is no requirement to remove the node from its parent node before appending it to some other node).- Parameters:
newChild- the node to append to the given parent node (commonly an element)- Returns:
- the appended child
-
cloneNode
@JsMethod public final BaseNode cloneNode(boolean deep)
Clone the node, and optionally, all of its contents.- Parameters:
deep- Iftrue, then node and its whole subtree including text.
Iffalse, only node will be cloned.
It has no effect on empty elements- Returns:
- the new node, cloned from this.
The new clone has no parent and is not part of the document
-
hasChildNodes
@JsMethod public final boolean hasChildNodes()
Returns a boolean indicating whether or not the element has any child nodes.- Returns:
- a boolean indicating whether or not the element has any child nodes
-
insertBefore
@JsMethod public final BaseNode insertBefore(BaseNode newChild, BaseNode refChild)
Inserts a node before the reference node as a child of a specified parent node.- Parameters:
newChild- the node to be inserted.refChild- the node before which new node is inserted.
If this isnull, then new node is inserted at the end of child nodes.- Returns:
- the added node
-
removeChild
@JsMethod public final BaseNode removeChild(BaseNode oldChild)
Removes a child node from the current element, which must be a child of the current node.- Parameters:
oldChild- is the child node to be removed from the DOM.- Returns:
- a reference to the removed child node
-
removeAllChildren
@JsOverlay public final void removeAllChildren()
Remove all children of the node.
-
-