public abstract class Node
extends java.lang.Object
implements java.lang.Cloneable
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:
| Modifier | Constructor and Description |
|---|---|
protected |
Node()
Initializes a new instance of this class.
|
protected |
Node(DocumentBase doc)
Initializes a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
abstract boolean |
accept(DocumentVisitor visitor)
Accepts a visitor.
|
void |
dd() |
Node |
deepClone(boolean isCloneChildren)
Creates a duplicate of the node.
|
CompositeNode |
getAncestor(java.lang.Class ancestorType)
Gets the first ancestor of the specified object type.
|
CompositeNode |
getAncestor(int ancestorType) |
int |
getCustomNodeId()
Specifies custom node identifier.
|
DocumentBase |
getDocument()
Gets the document to which this node belongs.
|
Node |
getNextSibling()
Gets the node immediately following this node.
|
abstract int |
getNodeType()
Gets the type of this node.
|
CompositeNode |
getParentNode()
Gets the immediate parent of this node.
|
Node |
getPreviousSibling()
Gets the node immediately preceding this node.
|
Range |
getRange()
Returns a Range object that represents the portion of a document that is contained in this node.
|
java.lang.String |
getText()
Gets the text of this node and of all its children.
|
boolean |
isComposite()
Returns true if this node can contain other nodes.
|
protected java.lang.Object |
memberwiseClone() |
Node |
nextPreOrder(Node rootNode)
Gets next node according to the pre-order tree traversal algorithm.
|
static java.lang.String |
nodeTypeToString(int nodeType) |
Node |
previousPreOrder(Node rootNode)
Gets the previous node according to the pre-order tree traversal algorithm.
|
void |
remove()
Removes itself from the parent.
|
void |
setCustomNodeId(int value)
Specifies custom node identifier.
|
java.lang.String |
toString() |
java.lang.String |
toString(int saveFormat) |
java.lang.String |
toString(SaveOptions saveOptions)
Exports the content of the node into a string using the specified save options.
|
protected static boolean |
visitorActionToBool(int action) |
protected Node()
protected Node(DocumentBase doc)
public abstract int getNodeType()
NodeType constants.public CompositeNode getParentNode()
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.
public DocumentBase getDocument()
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.
public Node getPreviousSibling()
public Node getNextSibling()
public boolean isComposite()
public Range getRange()
public Node deepClone(boolean isCloneChildren)
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.
isCloneChildren - True to recursively clone the subtree under the specified node; false to clone only the node itself.public abstract boolean accept(DocumentVisitor visitor) throws java.lang.Exception
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.
visitor - The visitor that will visit the nodes.java.lang.Exceptionprotected static boolean visitorActionToBool(int action)
public java.lang.String getText()
The returned string includes all control and special characters as described in ControlChar.
public CompositeNode getAncestor(java.lang.Class ancestorType)
ancestorType - The object type of the ancestor to retrieve.public CompositeNode getAncestor(int ancestorType)
public void remove()
public Node nextPreOrder(Node rootNode)
rootNode - The top node (limit) of traversal.public Node previousPreOrder(Node rootNode)
rootNode - The top node (limit) of traversal.public java.lang.String toString(int saveFormat)
throws java.lang.Exception
java.lang.Exceptionpublic java.lang.String toString(SaveOptions saveOptions) throws java.lang.Exception
saveOptions - Specifies the options that control how the node is saved.java.lang.Exceptionpublic static java.lang.String nodeTypeToString(int nodeType)
public int getCustomNodeId()
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.
int value.public void setCustomNodeId(int value)
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.
value - The corresponding int value.public java.lang.String toString()
toString in class java.lang.Objectpublic void dd()
protected java.lang.Object memberwiseClone()