The NodeSet class can act as either a NodeVector, NodeList, or NodeIterator. However, in order for it to act as a NodeVector or NodeList, it's required that setShouldCacheNodes(true) be called before the first nextNode() is called, in order that nodes can be added as they are fetched. Derived classes that implement iterators must override runTo(int index), in order that they may run the iteration to the given index.
Note that we directly implement the DOM's NodeIterator interface. We do not emulate all the behavior of the standard NodeIterator. In particular, we do not guarantee to present a "live view" of the document ... but in XSLT, the source document should never be mutated, so this should never be an issue.
Thought: Should NodeSet really implement NodeList and NodeIterator, or should there be specific subclasses of it which do so? The advantage of doing it all here is that all NodeSets will respond to the same calls; the disadvantage is that some of them may return less-than-enlightening results when you do so.
Modifier and Type | Field and Description |
---|---|
private int | m_blocksize
Size of blocks to allocate. |
protected transient boolean | m_cacheNodes
True if this list is cached. |
protected int | m_firstFree
Number of nodes in this NodeVector. |
private transient int | |
pack-priv Node[] | m_map
Array of nodes this points to. |
private int | m_mapSize
Size of the array this points to. |
protected transient int | m_next
If this node is being used as an iterator, the next index that nextNode() will return. |
Access | Constructor and Description |
---|---|
public | |
public | |
public | |
public | |
public | NodeSet(NodeIterator
Iterator which yields Nodes to be made members of the new set. ni)Create a NodeSet, and copy the members of the given NodeIterator into it. |
public |
Modifier and Type | Method and Description |
---|---|
public void | |
public void | |
public int | Returns: insertIndex.The node to be added. node, boolean true if we should test for doc order test, XPathContext The XPath runtime context. support)Add the node into a vector of nodes where it should occur in document order. |
public int | Returns: The index where it was inserted.The node to be added. node, XPathContext The XPath runtime context. support)Add the node into a vector of nodes where it should occur in document order. |
public void | |
public void | |
public void | addNodes(NodeIterator
NodeIterator which yields the nodes to be added. iterator)Copy NodeList members into this nodelist, adding in document order. |
public void | addNodesInDocOrder(NodeList
List of nodes to be added nodelist, XPathContext The XPath runtime context. support)Copy NodeList members into this nodelist, adding in document order. |
public void | addNodesInDocOrder(NodeIterator
NodeIterator which yields the nodes to be added. iterator, XPathContext The XPath runtime context. support)Copy NodeList members into this nodelist, adding in document order. |
private boolean | Returns: false always.index. start, int index. end, int index. testIndex, NodeList The nodelist to add. nodelist, XPathContext The XPath runtime context. support)Add the node list to this node set in document order. |
public void | |
public Object | Returns: A clone of thisOverrides java. Implements com. Get a cloned LocPathIterator. |
public NodeIterator | Returns: a new NodeSet of the same type, having the same state... except that the reset() operation has been called.Implements com. Get a cloned Iterator, and reset its state to the beginning of the iteration. |
public boolean | |
public void | detach()
Implements org. Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. |
public Node | |
public Node | Returns: the last fetched node.Implements com. Return the last fetched node. |
public int | Returns: The the current position index.Implements com. Get the current position, which is one less than the next nextNode() call will retrieve. |
public boolean | Returns: true for all iterators based on NodeSet, meaning that the contents of EntityRefrence nodes may be returned (though whatToShow says that the EntityReferences themselves are not shown.)Implements org. The value of this flag determines whether the children of entity reference nodes are visible to the iterator. |
public NodeFilter | Returns: null, which is slightly misleading. True, there is no user-written filter object, but in fact we are doing some very sophisticated custom filtering. A DOM purist might suggest returning a placeholder object just to indicate that this is not going to return all nodes selected by whatToShow.Implements org. The filter object used to screen nodes. |
public int | getLast()
Implements com. Get the index of the last node in this list. |
public int | Returns: integer indicating how many nodes are represented by this list.Implements org. The number of nodes in the list. |
public Node | Returns: The root node of the Iterator, as specified when it was created. For non-Iterator NodeSets, this will be null.Implements org. The root node of the |
public boolean | Returns: True if this list is cached.Get whether or not this is a cached node set. |
public int | Returns: integer used as a bit-array, containing flags defined in the DOM's NodeFilter class. The value will beSHOW_ALL & ~SHOW_ENTITY_REFERENCE , meaning that
only entity references are suppressed.Implements org. This attribute determines which node types are presented via the iterator. |
public int | Returns: the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.Node to look for elem, int Index of where to start the search index)Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method. |
public int | Returns: the index of the first occurrence of the object argument in this vector at position index or later in the vector; returns -1 if the object is not found.Node to look for elem)Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method. |
public void | insertElementAt(Node
Node to insert value, int Position where to insert at)Inserts the specified node in this vector at the specified index. |
public void | insertNode(Node
Node to be added n, int Offset at which the node is to be inserted,
with 0 being the first position. pos)Insert a node at a given position. |
public boolean | Returns: true if nextNode() would return the first node in the set, false if it would return a later one.Implements com. Tells if this NodeSet is "fresh", in other words, if the first nextNode() that is called will return the first node in the set. |
public Node | Returns: The node at theindex th position in the
NodeList , or null if that is not a valid
index.Index into the collection. index)Implements org. Returns the |
public Node | Returns: The nextNode in the set being iterated over, or
null if there are no more members in that set.Implements org. Returns the next node in the set and advances the position of the iterator in the set. |
public final Node | Returns: Node at the top of the stack or null if stack is empty.Return the node at the top of the stack without popping the stack. |
public final Node | Returns: Node at the tail of the vectorReturn the node at the tail of the vector without popping Special purpose method for TransformerImpl, pushElemTemplateElement. |
public final Node | Returns: Node one away from the tailReturn the node one position from the tail without popping. |
public final Node | Returns: the node at the tail of the vectorPop a node from the tail of the vector and return the result. |
public final Node | Returns: The top of the stack after it's been poppedPop a node from the tail of the vector and return the top of the stack after the pop. |
public final void | |
public final void | |
public Node | Returns: The previousNode in the set being iterated over,
ornull if there are no more members in that set.Implements org. Returns the previous node in the set and moves the position of the iterator backwards in the set. |
public final void | |
public final void | |
public void | |
public boolean | Returns: True if the node was successfully removedNode to remove from the list s)Removes the first occurrence of the argument from this vector. |
public void | |
public void | |
public void | |
public void | runTo(int
Position to advance (or retreat) to, with
0 requesting the reset ("fresh") position and -1 (or indeed
any out-of-bounds value) requesting the final position. index)Implements com. If an index is requested, NodeSet will call this method to run the iterator to the index. |
public void | setCurrentPos(int
Must be a valid index. i)Implements com. Set the current position in the node set. |
public void | setElementAt(Node
Node to set node, int Index of where to set the node index)Sets the component at the specified index of this vector to be the specified object. |
public void | setLast(int
the index of the last node in this list. last)Implements com. Set the index of the last node in this list. |
public void | setShouldCacheNodes(boolean
true if this node set should be cached. b)Implements com. If setShouldCacheNodes(true) is called, then nodes will be cached. |
public final void | |
public final void | |
public int | Returns: Number of nodes in this NodeVectorImplements com. Get the length of the list. |
m_blocksize | back to summary |
---|---|
private int m_blocksize Size of blocks to allocate. |
m_cacheNodes | back to summary |
---|---|
protected transient boolean m_cacheNodes True if this list is cached. |
m_firstFree | back to summary |
---|---|
protected int m_firstFree Number of nodes in this NodeVector. |
m_last | back to summary |
---|---|
private transient int m_last |
m_map | back to summary |
---|---|
pack-priv Node[] m_map Array of nodes this points to. |
m_mapSize | back to summary |
---|---|
private int m_mapSize Size of the array this points to. |
m_next | back to summary |
---|---|
protected transient int m_next If this node is being used as an iterator, the next index that nextNode() will return. |
NodeSet | back to summary |
---|---|
public NodeSet() Create an empty nodelist. |
NodeSet | back to summary |
---|---|
public NodeSet(int blocksize) Create an empty, using the given block size.
|
NodeSet | back to summary |
---|---|
public NodeSet(NodeList nodelist) Create a NodeSet, and copy the members of the given nodelist into it.
|
NodeSet | back to summary |
---|---|
public NodeSet(NodeSet nodelist) Create a NodeSet, and copy the members of the given NodeSet into it.
|
NodeSet | back to summary |
---|---|
public NodeSet(NodeIterator ni) Create a NodeSet, and copy the members of the given NodeIterator into it.
|
NodeSet | back to summary |
---|---|
public NodeSet(Node node) Create a NodeSet which contains the given Node.
|
addElement | back to summary |
---|---|
public void addElement(Node value) Append a Node onto the vector.
|
addNode | back to summary |
---|---|
public void addNode(Node n) Add a node to the NodeSet. Not all types of NodeSets support this operation
|
addNodeInDocOrder | back to summary |
---|---|
public int addNodeInDocOrder(Node node, boolean test, XPathContext support) Add the node into a vector of nodes where it should occur in document order.
|
addNodeInDocOrder | back to summary |
---|---|
public int addNodeInDocOrder(Node node, XPathContext support) Add the node into a vector of nodes where it should occur in document order.
|
addNodes | back to summary |
---|---|
public void addNodes(NodeList nodelist) Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.
|
addNodes | back to summary |
---|---|
public void addNodes(NodeSet ns) Copy NodeList members into this nodelist, adding in document order. Only genuine node references will be copied; nulls appearing in the source NodeSet will not be added to this one. In case you're wondering why this function is needed: NodeSet implements both NodeIterator and NodeList. If this method isn't provided, Java can't decide which of those to use when addNodes() is invoked. Providing the more-explicit match avoids that ambiguity.)
|
addNodes | back to summary |
---|---|
public void addNodes(NodeIterator iterator) Copy NodeList members into this nodelist, adding in document order. Null references are not added.
|
addNodesInDocOrder | back to summary |
---|---|
public void addNodesInDocOrder(NodeList nodelist, XPathContext support) Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.
|
addNodesInDocOrder | back to summary |
---|---|
public void addNodesInDocOrder(NodeIterator iterator, XPathContext support) Copy NodeList members into this nodelist, adding in document order. If a node is null, don't add it.
|
addNodesInDocOrder | back to summary |
---|---|
private boolean addNodesInDocOrder(int start, int end, int testIndex, NodeList nodelist, XPathContext support) Add the node list to this node set in document order.
|
appendNodes | back to summary |
---|---|
public void appendNodes(NodeSet nodes) Append the nodes to the list.
|
clone | back to summary |
---|---|
public Object clone() throws CloneNotSupportedException Overrides java. Implements com. Get a cloned LocPathIterator.
|
cloneWithReset | back to summary |
---|---|
public NodeIterator cloneWithReset() throws CloneNotSupportedException Implements com. Get a cloned Iterator, and reset its state to the beginning of the iteration.
|
contains | back to summary |
---|---|
public boolean contains(Node s) Tell if the table contains the given node.
|
detach | back to summary |
---|---|
public void detach() Implements org. Detaches the iterator from the set which it iterated over, releasing
any computational resources and placing the iterator in the INVALID
state. After This operation is a no-op in NodeSet, and will not cause INVALID_STATE_ERR to be raised by later operations. |
elementAt | back to summary |
---|---|
public Node elementAt(int i) Get the nth element.
|
getCurrentNode | back to summary |
---|---|
public Node getCurrentNode() Implements com. Return the last fetched node. Needed to support the UnionPathIterator.
|
getCurrentPos | back to summary |
---|---|
public int getCurrentPos() Implements com. Get the current position, which is one less than the next nextNode() call will retrieve. i.e. if you call getCurrentPos() and the return is 0, the next fetch will take place at index 1.
|
getExpandEntityReferences | back to summary |
---|---|
public boolean getExpandEntityReferences() Implements org. The value of this flag determines whether the children of entity
reference nodes are visible to the iterator. If false, they will be
skipped over.
|
getFilter | back to summary |
---|---|
public NodeFilter getFilter() Implements org. The filter object used to screen nodes. Filters are applied to further reduce (and restructure) the NodeIterator's view of the document. In our case, we will be using hardcoded filters built into our iterators... but getFilter() is part of the DOM's NodeIterator interface, so we have to support it.
|
getLast | back to summary |
---|---|
public int getLast() Implements com. Doc from com. Get the index of the last node in this list.
|
getLength | back to summary |
---|---|
public int getLength() Implements org. The number of nodes in the list. The range of valid child node indices is
0 to
|
getRoot | back to summary |
---|---|
public Node getRoot() Implements org. Doc from org. The root node of the
|
getShouldCacheNodes | back to summary |
---|---|
public boolean getShouldCacheNodes() Get whether or not this is a cached node set.
|
getWhatToShow | back to summary |
---|---|
public int getWhatToShow() Implements org. This attribute determines which node types are presented via the
iterator. The available set of constants is defined in the
|
indexOf | back to summary |
---|---|
public int indexOf(Node elem, int index) Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
|
indexOf | back to summary |
---|---|
public int indexOf(Node elem) Searches for the first occurence of the given argument, beginning the search at index, and testing for equality using the equals method.
|
insertElementAt | back to summary |
---|---|
public void insertElementAt(Node value, int at) Inserts the specified node in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.
|
insertNode | back to summary |
---|---|
public void insertNode(Node n, int pos) Insert a node at a given position.
|
isFresh | back to summary |
---|---|
public boolean isFresh() Implements com. Tells if this NodeSet is "fresh", in other words, if the first nextNode() that is called will return the first node in the set.
|
item | back to summary |
---|---|
public Node item(int index) Implements org. Returns the Todo What happens if index is out of range?
|
nextNode | back to summary |
---|---|
public Node nextNode() throws DOMException Implements org. Returns the next node in the set and advances the position of the iterator in the set. After a NodeIterator is created, the first call to nextNode() returns the first node in the set.
|
peepOrNull | back to summary |
---|---|
public final Node peepOrNull() Return the node at the top of the stack without popping the stack. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.
|
peepTail | back to summary |
---|---|
public final Node peepTail() Return the node at the tail of the vector without popping Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.
|
peepTailSub1 | back to summary |
---|---|
public final Node peepTailSub1() Return the node one position from the tail without popping. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.
|
pop | back to summary |
---|---|
public final Node pop() Pop a node from the tail of the vector and return the result.
|
popAndTop | back to summary |
---|---|
public final Node popAndTop() Pop a node from the tail of the vector and return the top of the stack after the pop.
|
popPair | back to summary |
---|---|
public final void popPair() Pop a pair of nodes from the tail of the stack. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical. |
popQuick | back to summary |
---|---|
public final void popQuick() Pop a node from the tail of the vector. |
previousNode | back to summary |
---|---|
public Node previousNode() throws DOMException Implements org. Returns the previous node in the set and moves the position of the iterator backwards in the set.
|
push | back to summary |
---|---|
public final void push(Node value) Append a Node onto the vector.
|
pushPair | back to summary |
---|---|
public final void pushPair(Node v1, Node v2) Push a pair of nodes into the stack. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical. |
removeAllElements | back to summary |
---|---|
public void removeAllElements() Inserts the specified node in this vector at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously. |
removeElement | back to summary |
---|---|
public boolean removeElement(Node s) Removes the first occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.
|
removeElementAt | back to summary |
---|---|
public void removeElementAt(int i) Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously.
|
removeNode | back to summary |
---|---|
public void removeNode(Node n) Remove a node.
|
reset | back to summary |
---|---|
public void reset() Implements com. Reset the iterator. May have no effect on non-iterator Nodesets. |
runTo | back to summary |
---|---|
public void runTo(int index) Implements com. If an index is requested, NodeSet will call this method to run the iterator to the index. By default this sets m_next to the index. If the index argument is -1, this signals that the iterator should be run to the end.
|
setCurrentPos | back to summary |
---|---|
public void setCurrentPos(int i) Implements com. Set the current position in the node set.
|
setElementAt | back to summary |
---|---|
public void setElementAt(Node node, int index) Sets the component at the specified index of this vector to be the specified object. The previous component at that position is discarded. The index must be a value greater than or equal to 0 and less than the current size of the vector.
|
setLast | back to summary |
---|---|
public void setLast(int last) Implements com. Doc from com. Set the index of the last node in this list.
|
setShouldCacheNodes | back to summary |
---|---|
public void setShouldCacheNodes(boolean b) Implements com. If setShouldCacheNodes(true) is called, then nodes will be cached. They are not cached by default. This switch must be set before the first call to nextNode is made, to ensure that all nodes are cached.
|
setTail | back to summary |
---|---|
public final void setTail(Node n) Set the tail of the stack to the given node. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.
|
setTailSub1 | back to summary |
---|---|
public final void setTailSub1(Node n) Set the given node one position from the tail. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.
|
size | back to summary |
---|---|
public int size() Implements com. Get the length of the list.
|