java.lang.Objectcom.aspose.words.NodeCollection
public class NodeCollection
NodeCollection does not own the nodes it contains, rather, is just a selection of nodes
of the specified type, but the nodes are stored in the tree under their respective parent nodes. NodeCollection supports indexed access, iteration and provides add and remove methods. The NodeCollection collection is "live", i.e. changes to the children of the node object
that it was created from are immediately reflected in the nodes returned by the NodeCollection
properties and methods. NodeCollection is returned by NodeCollection can be "flat" and contain only immediate children of the node it was created
from, or it can be "deep" and contain all descendant children.
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Gets the number of nodes in the collection. | ||
Node | get(int index) | |
Retrieves a node at the given index. |
Method Summary | ||
---|---|---|
void | add(Node node) | |
Adds a node to the end of the collection. | ||
void | clear() | |
Removes all nodes from this collection and from the document. | ||
boolean | contains(Node node) | |
Determines whether a node is in the collection. | ||
CompositeNode | getContainer() | |
Reserved for internal use. | ||
Node | getNextMatchingNode(aspose.obfuscated.type curNode) | |
Reserved for internal use. | ||
int | indexOf(Node node) | |
Returns the zero-based index of the specified node. | ||
void | insert(int index, Node node) | |
Inserts a node into the collection at the specified index. | ||
java.util.Iterator | iterator() | |
Provides a simple "foreach" style iteration over the collection of nodes. | ||
void | remove(Node node) | |
Removes the node from the collection and from the document. | ||
void | removeAt(int index) | |
Removes the node at the specified index from the collection and from the document. | ||
Aspose.Words.Node[] | toArray() | |
Copies all nodes from the collection to a new array of nodes. |
Property Getters/Setters Detail |
---|
getCount | |
public int getCount() |
get | |
public Node get(int index) |
The index is zero-based.
Negative indexes are allowed and indicate access from the back of the collection. For example -1 means the last item, -2 means the second before last and so on.
If index is greater than or equal to the number of items in the list, this returns a null reference.
If index is negative and its absolute value is greater than the number of items in the list, this returns a null reference.
index
- An index into the collection of nodes.Method Detail |
---|
add | |
public void add(Node node) |
The node is inserted as a child into the node object from which the collection was created.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use
node
- The node to be added to the end of the collection.clear | |
public void clear() |
contains | |
public boolean contains(Node node) |
This method performs a linear search; therefore, the average execution time is proportional to Count.
node
- The node to locate.getContainer | |
public CompositeNode getContainer() |
getNextMatchingNode | |
public Node getNextMatchingNode(aspose.obfuscated.type curNode) throws java.lang.Exception |
indexOf | |
public int indexOf(Node node) |
This method performs a linear search; therefore, the average execution time is proportional to Count.
node
- The node to locate.insert | |
public void insert(int index, Node node) |
The node is inserted as a child into the node object from which the collection was created.
If the index is equal to or greater than Count, the node is added at the end of the collection.
If the index is negative and its absolute value is greater than Count, the node is added at the end of the collection.
If the newChild is already in the tree, it is first removed.
If the node being inserted was created from another document, you should use
index
- The zero-based index of the node.
Negative indexes are allowed and indicate access from the back of the list.
For example -1 means the last node, -2 means the second before last and so on.node
- The node to insert.iterator | |
public java.util.Iterator iterator() |
remove | |
public void remove(Node node) |
node
- The node to remove.removeAt | |
public void removeAt(int index) |
index
- The zero-based index of the node.
Negative indexes are allowed and indicate access from the back of the list.
For example -1 means the last node, -2 means the second before last and so on.toArray | |
public Aspose.Words.Node[] toArray() |
You should not be adding/removing nodes while iterating over a collection of nodes because it invalidates the iterator and requires refreshes for live collections.
To be able to add/remove nodes during iteration, use this method to copy nodes into a fixed-size array and then iterate over the array.