Top Description Fields Constructors Methods
com.sun.org.apache.xpath.internal

public Class NodeSet

extends Object
implements NodeList, NodeIterator, Cloneable, ContextNodeList
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xpath.internal.axes.ContextNodeList, java.lang.Cloneable, org.w3c.dom.traversal.NodeIterator, org.w3c.dom.NodeList
Imports
com.sun.org.apache.xalan.internal.res.XSLMessages, com.sun.org.apache.xml.internal.utils.DOM2Helper, com.sun.org.apache.xpath.internal.axes.ContextNodeList, com.sun.org.apache.xpath.internal.res.XPATHErrorResources, org.w3c.dom.DOMException, .Node, .NodeList, org.w3c.dom.traversal.NodeFilter, .NodeIterator

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.

Field Summary

Modifier and TypeField 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.

Constructor Summary

AccessConstructor and Description
public
NodeSet()

Create an empty nodelist.

public
NodeSet(int
Size of blocks to allocate
blocksize
)

Create an empty, using the given block size.

public
NodeSet(NodeList
List of Nodes to be made members of the new set.
nodelist
)

Create a NodeSet, and copy the members of the given nodelist into it.

public
NodeSet(NodeSet
Set of Nodes to be made members of the new set.
nodelist
)

Create a NodeSet, and copy the members of the given NodeSet into it.

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
NodeSet(Node
Single node to be added to the new set.
node
)

Create a NodeSet which contains the given Node.

Method Summary

Modifier and TypeMethod and Description
public void
addElement(Node
Node to add to the vector
value
)

Append a Node onto the vector.

public void
addNode(Node
Node to be added
n
)

Add a node to the NodeSet.

public int

Returns:

insertIndex.
addNodeInDocOrder
(Node
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.
addNodeInDocOrder
(Node
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
addNodes(NodeList
List of nodes which should now be referenced by this NodeSet.
nodelist
)

Copy NodeList members into this nodelist, adding in document order.

public void
addNodes(NodeSet
NodeSet whose members should be merged into this NodeSet.
ns
)

Copy NodeList members into this nodelist, adding in document order.

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.
addNodesInDocOrder
(int
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
appendNodes(NodeSet
NodeVector to append to this list
nodes
)

Append the nodes to the list.

public Object

Returns:

A clone of this
clone
()

Overrides java.lang.Object.clone.

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.clone.

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.
cloneWithReset
()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.cloneWithReset.

Get a cloned Iterator, and reset its state to the beginning of the iteration.

public boolean

Returns:

True if the given node was found.
contains
(Node
Node to look for
s
)

Tell if the table contains the given node.

public void
detach()

Implements org.w3c.dom.traversal.NodeIterator.detach.

Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state.

public Node

Returns:

Node at specified index
elementAt
(int
Index of node to get
i
)

Get the nth element.

public Node

Returns:

the last fetched node.
getCurrentNode
()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.getCurrentNode.

Return the last fetched node.

public int

Returns:

The the current position index.
getCurrentPos
()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.getCurrentPos.

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.)
getExpandEntityReferences
()

Implements org.w3c.dom.traversal.NodeIterator.getExpandEntityReferences.

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.
getFilter
()

Implements org.w3c.dom.traversal.NodeIterator.getFilter.

The filter object used to screen nodes.

public int
getLast()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.getLast.

Get the index of the last node in this list.

public int

Returns:

integer indicating how many nodes are represented by this list.
getLength
()

Implements org.w3c.dom.NodeList.getLength.

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.
getRoot
()

Implements org.w3c.dom.traversal.NodeIterator.getRoot.

The root node of the NodeIterator, as specified when it was created.

public boolean

Returns:

True if this list is cached.
getShouldCacheNodes
()

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 be SHOW_ALL & ~SHOW_ENTITY_REFERENCE, meaning that only entity references are suppressed.
getWhatToShow
()

Implements org.w3c.dom.traversal.NodeIterator.getWhatToShow.

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.
indexOf
(Node
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.
indexOf
(Node
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.
isFresh
()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.isFresh.

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 the indexth position in the NodeList, or null if that is not a valid index.
item
(int
Index into the collection.
index
)

Implements org.w3c.dom.NodeList.item.

Returns the indexth item in the collection.

public Node

Returns:

The next Node in the set being iterated over, or null if there are no more members in that set.
nextNode
()

Implements org.w3c.dom.traversal.NodeIterator.nextNode.

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.
peepOrNull
()

Return the node at the top of the stack without popping the stack.

public final Node

Returns:

Node at the tail of the vector
peepTail
()

Return 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 tail
peepTailSub1
()

Return the node one position from the tail without popping.

public final Node

Returns:

the node at the tail of the vector
pop
()

Pop 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 popped
popAndTop
()

Pop a node from the tail of the vector and return the top of the stack after the pop.

public final void
popPair()

Pop a pair of nodes from the tail of the stack.

public final void
popQuick()

Pop a node from the tail of the vector.

public Node

Returns:

The previous Node in the set being iterated over, ornull if there are no more members in that set.
previousNode
()

Implements org.w3c.dom.traversal.NodeIterator.previousNode.

Returns the previous node in the set and moves the position of the iterator backwards in the set.

public final void
push(Node
Node to add to the vector
value
)

Append a Node onto the vector.

public final void
pushPair(Node
First node to add to vector
v1
,
Node
Second node to add to vector
v2
)

Push a pair of nodes into the stack.

public void
removeAllElements()

Inserts the specified node in this vector at the specified index.

public boolean

Returns:

True if the node was successfully removed
removeElement
(Node
Node to remove from the list
s
)

Removes the first occurrence of the argument from this vector.

public void
removeElementAt(int
Index of node to remove
i
)

Deletes the component at the specified index.

public void
removeNode(Node
Node to be added
n
)

Remove a node.

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.sun.org.apache.xpath.internal.axes.ContextNodeList.runTo.

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.sun.org.apache.xpath.internal.axes.ContextNodeList.setCurrentPos.

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.sun.org.apache.xpath.internal.axes.ContextNodeList.setLast.

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.sun.org.apache.xpath.internal.axes.ContextNodeList.setShouldCacheNodes.

If setShouldCacheNodes(true) is called, then nodes will be cached.

public final void
setTail(Node
Node to set at the tail of vector
n
)

Set the tail of the stack to the given node.

public final void
setTailSub1(Node
Node to set
n
)

Set the given node one position from the tail.

public int

Returns:

Number of nodes in this NodeVector
size
()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.size.

Get the length of the list.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_blocksizeback to summary
private int m_blocksize

Size of blocks to allocate.

m_cacheNodesback to summary
protected transient boolean m_cacheNodes

True if this list is cached.

m_firstFreeback to summary
protected int m_firstFree

Number of nodes in this NodeVector.

m_lastback to summary
private transient int m_last
m_mapback to summary
pack-priv Node[] m_map

Array of nodes this points to.

m_mapSizeback to summary
private int m_mapSize

Size of the array this points to.

m_nextback to summary
protected transient int m_next

If this node is being used as an iterator, the next index that nextNode() will return.

Constructor Detail

NodeSetback to summary
public NodeSet()

Create an empty nodelist.

NodeSetback to summary
public NodeSet(int blocksize)

Create an empty, using the given block size.

Parameters
blocksize:int

Size of blocks to allocate

NodeSetback to summary
public NodeSet(NodeList nodelist)

Create a NodeSet, and copy the members of the given nodelist into it.

Parameters
nodelist:NodeList

List of Nodes to be made members of the new set.

NodeSetback to summary
public NodeSet(NodeSet nodelist)

Create a NodeSet, and copy the members of the given NodeSet into it.

Parameters
nodelist:NodeSet

Set of Nodes to be made members of the new set.

NodeSetback to summary
public NodeSet(NodeIterator ni)

Create a NodeSet, and copy the members of the given NodeIterator into it.

Parameters
ni:NodeIterator

Iterator which yields Nodes to be made members of the new set.

NodeSetback to summary
public NodeSet(Node node)

Create a NodeSet which contains the given Node.

Parameters
node:Node

Single node to be added to the new set.

Method Detail

addElementback to summary
public void addElement(Node value)

Append a Node onto the vector.

Parameters
value:Node

Node to add to the vector

addNodeback to summary
public void addNode(Node n)

Add a node to the NodeSet. Not all types of NodeSets support this operation

Parameters
n:Node

Node to be added

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodeInDocOrderback 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.

Parameters
node:Node

The node to be added.

test:boolean

true if we should test for doc order

support:XPathContext

The XPath runtime context.

Returns:int

insertIndex.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodeInDocOrderback to summary
public int addNodeInDocOrder(Node node, XPathContext support)

Add the node into a vector of nodes where it should occur in document order.

Parameters
node:Node

The node to be added.

support:XPathContext

The XPath runtime context.

Returns:int

The index where it was inserted.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodesback 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.

Parameters
nodelist:NodeList

List of nodes which should now be referenced by this NodeSet.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodesback 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.)

Parameters
ns:NodeSet

NodeSet whose members should be merged into this NodeSet.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodesback to summary
public void addNodes(NodeIterator iterator)

Copy NodeList members into this nodelist, adding in document order. Null references are not added.

Parameters
iterator:NodeIterator

NodeIterator which yields the nodes to be added.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodesInDocOrderback 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.

Parameters
nodelist:NodeList

List of nodes to be added

support:XPathContext

The XPath runtime context.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodesInDocOrderback 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.

Parameters
iterator:NodeIterator

NodeIterator which yields the nodes to be added.

support:XPathContext

The XPath runtime context.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
addNodesInDocOrderback 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.

Parameters
start:int

index.

end:int

index.

testIndex:int

index.

nodelist:NodeList

The nodelist to add.

support:XPathContext

The XPath runtime context.

Returns:boolean

false always.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
appendNodesback to summary
public void appendNodes(NodeSet nodes)

Append the nodes to the list.

Parameters
nodes:NodeSet

NodeVector to append to this list

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides java.lang.Object.clone.

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.clone.

Get a cloned LocPathIterator.

Returns:Object

A clone of this

Exceptions
CloneNotSupportedException:

Doc from java.lang.Object.clone.

if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

cloneWithResetback to summary
public NodeIterator cloneWithReset() throws CloneNotSupportedException

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.cloneWithReset.

Get a cloned Iterator, and reset its state to the beginning of the iteration.

Returns:NodeIterator

a new NodeSet of the same type, having the same state... except that the reset() operation has been called.

Exceptions
CloneNotSupportedException:
if this subclass of NodeSet does not support the clone() operation.
containsback to summary
public boolean contains(Node s)

Tell if the table contains the given node.

Parameters
s:Node

Node to look for

Returns:boolean

True if the given node was found.

detachback to summary
public void detach()

Implements org.w3c.dom.traversal.NodeIterator.detach.

Detaches the iterator from the set which it iterated over, releasing any computational resources and placing the iterator in the INVALID state. Afterdetach has been invoked, calls to nextNode orpreviousNode will raise the exception INVALID_STATE_ERR.

This operation is a no-op in NodeSet, and will not cause INVALID_STATE_ERR to be raised by later operations.

elementAtback to summary
public Node elementAt(int i)

Get the nth element.

Parameters
i:int

Index of node to get

Returns:Node

Node at specified index

getCurrentNodeback to summary
public Node getCurrentNode()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.getCurrentNode.

Return the last fetched node. Needed to support the UnionPathIterator.

Returns:Node

the last fetched node.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a cached type, and thus doesn't permit indexed access.
getCurrentPosback to summary
public int getCurrentPos()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.getCurrentPos.

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.

Returns:int

The the current position index.

getExpandEntityReferencesback to summary
public boolean getExpandEntityReferences()

Implements org.w3c.dom.traversal.NodeIterator.getExpandEntityReferences.

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.
To produce a view of the document that has entity references expanded and does not expose the entity reference node itself, use the whatToShow flags to hide the entity reference node and set expandEntityReferences to true when creating the iterator. To produce a view of the document that has entity reference nodes but no entity expansion, use the whatToShow flags to show the entity reference node and set expandEntityReferences to false.

Returns:boolean

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.)

getFilterback to summary
public NodeFilter getFilter()

Implements org.w3c.dom.traversal.NodeIterator.getFilter.

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.

Returns:NodeFilter

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.

getLastback to summary
public int getLast()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.getLast.

Doc from com.sun.org.apache.xpath.internal.axes.ContextNodeList.getLast.

Get the index of the last node in this list.

Returns:int

the index of the last node in this list.

getLengthback to summary
public int getLength()

Implements org.w3c.dom.NodeList.getLength.

The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive. Note that this operation requires finding all the matching nodes, which may defeat attempts to defer that work.

Returns:int

integer indicating how many nodes are represented by this list.

getRootback to summary
public Node getRoot()

Implements org.w3c.dom.traversal.NodeIterator.getRoot.

Doc from org.w3c.dom.traversal.NodeIterator.getRoot.

The root node of the NodeIterator, as specified when it was created.

Returns:Node

The root node of the Iterator, as specified when it was created. For non-Iterator NodeSets, this will be null.

getShouldCacheNodesback to summary
public boolean getShouldCacheNodes()

Get whether or not this is a cached node set.

Returns:boolean

True if this list is cached.

getWhatToShowback to summary
public int getWhatToShow()

Implements org.w3c.dom.traversal.NodeIterator.getWhatToShow.

This attribute determines which node types are presented via the iterator. The available set of constants is defined in the NodeFilter interface. For NodeSets, the mask has been hardcoded to show all nodes except EntityReference nodes, which have no equivalent in the XPath data model.

Returns:int

integer used as a bit-array, containing flags defined in the DOM's NodeFilter class. The value will be SHOW_ALL & ~SHOW_ENTITY_REFERENCE, meaning that only entity references are suppressed.

indexOfback 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.

Parameters
elem:Node

Node to look for

index:int

Index of where to start the search

Returns:int

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.

indexOfback 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.

Parameters
elem:Node

Node to look for

Returns:int

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.

insertElementAtback 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.

Parameters
value:Node

Node to insert

at:int

Position where to insert

insertNodeback to summary
public void insertNode(Node n, int pos)

Insert a node at a given position.

Parameters
n:Node

Node to be added

pos:int

Offset at which the node is to be inserted, with 0 being the first position.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
isFreshback to summary
public boolean isFresh()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.isFresh.

Tells if this NodeSet is "fresh", in other words, if the first nextNode() that is called will return the first node in the set.

Returns:boolean

true if nextNode() would return the first node in the set, false if it would return a later one.

itemback to summary
public Node item(int index)

Implements org.w3c.dom.NodeList.item.

Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.

Todo

What happens if index is out of range?

Parameters
index:int

Index into the collection.

Returns:Node

The node at the indexth position in the NodeList, or null if that is not a valid index.

nextNodeback to summary
public Node nextNode() throws DOMException

Implements org.w3c.dom.traversal.NodeIterator.nextNode.

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.

Returns:Node

The next Node in the set being iterated over, or null if there are no more members in that set.

Exceptions
DOMException:
INVALID_STATE_ERR: Raised if this method is called after the detach method was invoked.
peepOrNullback 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.

Returns:Node

Node at the top of the stack or null if stack is empty.

peepTailback 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.

Returns:Node

Node at the tail of the vector

peepTailSub1back to summary
public final Node peepTailSub1()

Return the node one position from the tail without popping. Special purpose method for TransformerImpl, pushElemTemplateElement. Performance critical.

Returns:Node

Node one away from the tail

popback to summary
public final Node pop()

Pop a node from the tail of the vector and return the result.

Returns:Node

the node at the tail of the vector

popAndTopback 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.

Returns:Node

The top of the stack after it's been popped

popPairback 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.

popQuickback to summary
public final void popQuick()

Pop a node from the tail of the vector.

previousNodeback to summary
public Node previousNode() throws DOMException

Implements org.w3c.dom.traversal.NodeIterator.previousNode.

Returns the previous node in the set and moves the position of the iterator backwards in the set.

Returns:Node

The previous Node in the set being iterated over, ornull if there are no more members in that set.

Exceptions
DOMException:
INVALID_STATE_ERR: Raised if this method is called after the detach method was invoked.
RuntimeException:
thrown if this NodeSet is not of a cached type, and hence doesn't know what the previous node was.
pushback to summary
public final void push(Node value)

Append a Node onto the vector.

Parameters
value:Node

Node to add to the vector

pushPairback 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.

Parameters
v1:Node

First node to add to vector

v2:Node

Second node to add to vector

removeAllElementsback 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.

removeElementback 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.

Parameters
s:Node

Node to remove from the list

Returns:boolean

True if the node was successfully removed

removeElementAtback 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.

Parameters
i:int

Index of node to remove

removeNodeback to summary
public void removeNode(Node n)

Remove a node.

Parameters
n:Node

Node to be added

Exceptions
RuntimeException:
thrown if this NodeSet is not of a mutable type.
resetback to summary
public void reset()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.reset.

Reset the iterator. May have no effect on non-iterator Nodesets.

runToback to summary
public void runTo(int index)

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.runTo.

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.

Parameters
index: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.

Exceptions
RuntimeException:
thrown if this NodeSet is not one of the types which supports indexing/counting.
setCurrentPosback to summary
public void setCurrentPos(int i)

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.setCurrentPos.

Set the current position in the node set.

Parameters
i:int

Must be a valid index.

Exceptions
RuntimeException:
thrown if this NodeSet is not of a cached type, and thus doesn't permit indexed access.
setElementAtback 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.

Parameters
node:Node

Node to set

index:int

Index of where to set the node

setLastback to summary
public void setLast(int last)

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.setLast.

Doc from com.sun.org.apache.xpath.internal.axes.ContextNodeList.setLast.

Set the index of the last node in this list.

Parameters
last:int

the index of the last node in this list.

setShouldCacheNodesback to summary
public void setShouldCacheNodes(boolean b)

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.setShouldCacheNodes.

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.

Parameters
b:boolean

true if this node set should be cached.

Exceptions
RuntimeException:
thrown if an attempt is made to request caching after we've already begun stepping through the nodes in this set.
setTailback 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.

Parameters
n:Node

Node to set at the tail of vector

setTailSub1back 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.

Parameters
n:Node

Node to set

sizeback to summary
public int size()

Implements com.sun.org.apache.xpath.internal.axes.ContextNodeList.size.

Get the length of the list.

Returns:int

Number of nodes in this NodeVector