Node
Inheritance: java.lang.Object
All Implemented Interfaces: java.lang.Cloneable
public abstract class Node implements Cloneable
Base class for all nodes of a Word document.
To learn more, visit the Aspose.Words Document Object Model (DOM) documentation article.
A document is represented as a tree of nodes, similar to DOM or XmlDocument.
For more info see the Composite design pattern.
The Node class:
- Defines the child node interface.
- Defines the interface for visiting nodes.
- Provides default cloning capability.
- Implements parent node and owner document mechanisms.
- Implements access to sibling nodes.
Methods
Method | Description |
---|---|
accept(DocumentVisitor visitor) | Accepts a visitor. |
dd() | |
deepClone(boolean isCloneChildren) | Creates a duplicate of the node. |
equals(Object arg0) | |
getAncestor(int ancestorType) | |
getAncestor(Class ancestorType) | Gets the first ancestor of the specified object type. |
getClass() | |
getCustomNodeId() | Specifies custom node identifier. |
getDocument() | Gets the document to which this node belongs. |
getNextSibling() | Gets the node immediately following this node. |
getNodeType() | Gets the type of this node. |
getParentNode() | Gets the immediate parent of this node. |
getPreviousSibling() | Gets the node immediately preceding this node. |
getRange() | Returns a Range object that represents the portion of a document that is contained in this node. |
getText() | Gets the text of this node and of all its children. |
hashCode() | |
isComposite() | Returns true if this node can contain other nodes. |
nextPreOrder(Node rootNode) | Gets next node according to the pre-order tree traversal algorithm. |
nodeTypeToString(int nodeType) | |
notify() | |
notifyAll() | |
previousPreOrder(Node rootNode) | Gets the previous node according to the pre-order tree traversal algorithm. |
remove() | Removes itself from the parent. |
setCustomNodeId(int value) | Specifies custom node identifier. |
toString() | |
toString(SaveOptions saveOptions) | Exports the content of the node into a string using the specified save options. |
toString(int saveFormat) | |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
accept(DocumentVisitor visitor)
public abstract boolean accept(DocumentVisitor visitor)
Accepts a visitor.
Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.
For more info see the Visitor design pattern.
Parameters:
Parameter | Type | Description |
---|---|---|
visitor | DocumentVisitor | The visitor that will visit the nodes. |
Returns: boolean - True if all nodes were visited; false if DocumentVisitor stopped the operation before visiting all nodes.
dd()
public void dd()
deepClone(boolean isCloneChildren)
public Node deepClone(boolean isCloneChildren)
Creates a duplicate of the node.
This method serves as a copy constructor for nodes. The cloned node has no parent, but belongs to the same document as the original node.
This method always performs a deep copy of the node. The isCloneChildren parameter specifies whether to perform copy all child nodes as well.
Parameters:
Parameter | Type | Description |
---|---|---|
isCloneChildren | boolean | True to recursively clone the subtree under the specified node; false to clone only the node itself. |
Returns: Node - The cloned node.
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
getAncestor(int ancestorType)
public CompositeNode getAncestor(int ancestorType)
Parameters:
Parameter | Type | Description |
---|---|---|
ancestorType | int |
Returns: CompositeNode
getAncestor(Class ancestorType)
public CompositeNode getAncestor(Class ancestorType)
Gets the first ancestor of the specified object type.
Parameters:
Parameter | Type | Description |
---|---|---|
ancestorType | java.lang.Class | The object type of the ancestor to retrieve. |
Returns: CompositeNode - The ancestor of the specified type or null if no ancestor of this type was found.
The ancestor type matches if it is equal to ancestorType or derived from ancestorType .
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class>
getCustomNodeId()
public int getCustomNodeId()
Specifies custom node identifier.
Default is zero.
This identifier can be set and used arbitrarily. For example, as a key to get external data.
Important note, specified value is not saved to an output file and exists only during the node lifetime.
Returns: int - The corresponding int value.
getDocument()
public DocumentBase getDocument()
Gets the document to which this node belongs.
The node always belongs to a document even if it has just been created and not yet added to the tree, or if it has been removed from the tree.
Returns: DocumentBase - The document to which this node belongs.
getNextSibling()
public Node getNextSibling()
Gets the node immediately following this node. If there is no next node, a null is returned.
Returns: Node - The node immediately following this node.
getNodeType()
public abstract int getNodeType()
Gets the type of this node.
Returns: int - The type of this node. The returned value is one of NodeType constants.
getParentNode()
public CompositeNode getParentNode()
Gets the immediate parent of this node.
If a node has just been created and not yet added to the tree, or if it has been removed from the tree, the parent is null .
Returns: CompositeNode - The immediate parent of this node.
getPreviousSibling()
public Node getPreviousSibling()
Gets the node immediately preceding this node. If there is no preceding node, a null is returned.
Returns: Node - The node immediately preceding this node.
getRange()
public Range getRange()
Returns a Range object that represents the portion of a document that is contained in this node.
Returns: Range - A Range object that represents the portion of a document that is contained in this node.
getText()
public String getText()
Gets the text of this node and of all its children.
The returned string includes all control and special characters as described in ControlChar.
Returns: java.lang.String
hashCode()
public native int hashCode()
Returns: int
isComposite()
public boolean isComposite()
Returns true if this node can contain other nodes. (31574,6)
Returns: boolean - { true if this node can contain other nodes.
nextPreOrder(Node rootNode)
public Node nextPreOrder(Node rootNode)
Gets next node according to the pre-order tree traversal algorithm.
Parameters:
Parameter | Type | Description |
---|---|---|
rootNode | Node | The top node (limit) of traversal. |
Returns: Node - Next node in pre-order order. Null if reached the rootNode .
nodeTypeToString(int nodeType)
public static String nodeTypeToString(int nodeType)
Parameters:
Parameter | Type | Description |
---|---|---|
nodeType | int |
Returns: java.lang.String
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
previousPreOrder(Node rootNode)
public Node previousPreOrder(Node rootNode)
Gets the previous node according to the pre-order tree traversal algorithm.
Parameters:
Parameter | Type | Description |
---|---|---|
rootNode | Node | The top node (limit) of traversal. |
Returns: Node - Previous node in pre-order order. Null if reached the rootNode .
remove()
public void remove()
Removes itself from the parent.
setCustomNodeId(int value)
public void setCustomNodeId(int value)
Specifies custom node identifier.
Default is zero.
This identifier can be set and used arbitrarily. For example, as a key to get external data.
Important note, specified value is not saved to an output file and exists only during the node lifetime.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The corresponding int value. |
toString()
public String toString()
Returns: java.lang.String
toString(SaveOptions saveOptions)
public String toString(SaveOptions saveOptions)
Exports the content of the node into a string using the specified save options.
Parameters:
Parameter | Type | Description |
---|---|---|
saveOptions | SaveOptions | Specifies the options that control how the node is saved. |
Returns: java.lang.String - The content of the node in the specified format.
toString(int saveFormat)
public String toString(int saveFormat)
Parameters:
Parameter | Type | Description |
---|---|---|
saveFormat | int |
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |