org.apache.xalan.xsltc.dom
Class KeyIndex.KeyIndexIterator

java.lang.Object
  extended by org.apache.xml.dtm.ref.DTMAxisIteratorBase
      extended by org.apache.xalan.xsltc.dom.MultiValuedNodeHeapIterator
          extended by org.apache.xalan.xsltc.dom.KeyIndex.KeyIndexIterator
All Implemented Interfaces:
java.lang.Cloneable, DTMAxisIterator
Enclosing class:
KeyIndex

public class KeyIndex.KeyIndexIterator
extends MultiValuedNodeHeapIterator

An iterator representing the result of a reference to either the XSLT key function or the XPath id function.


Nested Class Summary
protected  class KeyIndex.KeyIndexIterator.KeyIndexHeapNode
          Represents the DTM nodes retrieved for one key value or one string argument to id for use as one heap node in a MultiValuedNodeHeapIterator.
 
Nested classes/interfaces inherited from class org.apache.xalan.xsltc.dom.MultiValuedNodeHeapIterator
MultiValuedNodeHeapIterator.HeapNode
 
Field Summary
private  boolean _isKeyIterator
          Indicates whether this object represents the result of a reference to the key function (true) or the id function (false).
private  java.lang.String _keyValue
          This field contains the iterator representing a non-node-set key value argument to the key function or a non-node-set argument to the id function.
private  DTMAxisIterator _keyValueIterator
          This field contains the iterator representing a node set key value argument to the key function or a node set argument to the id function.
private  IntegerArray _nodes
          A reference to the key function that only has one key value or to the id function that has only one string argument can be optimized to ignore the multi-valued heap.
 
Fields inherited from class org.apache.xml.dtm.ref.DTMAxisIteratorBase
_includeSelf, _isRestartable, _last, _markedNode, _position, _startNode
 
Fields inherited from interface org.apache.xml.dtm.DTMAxisIterator
END
 
Constructor Summary
KeyIndex.KeyIndexIterator(DTMAxisIterator keyValues, boolean isKeyIterator)
          Constructor used when the argument to key or id is a node set.
KeyIndex.KeyIndexIterator(java.lang.String keyValue, boolean isKeyIterator)
          Constructor used when the argument to key or id is not a node set.
 
Method Summary
 int getLast()
          Returns the number of nodes in this iterator.
 int getNodeByPosition(int position)
          Return the node at the given position.
protected  void init()
          Evaluate the reference to the key or id function with the context specified by setStartNode(int) and set up this iterator to iterate over the DTM nodes that are to be returned.
protected  IntegerArray lookupNodes(int root, java.lang.String keyValue)
          Retrieve nodes for a particular key value or a particular id argument value.
 int next()
          Get the next node in the iteration.
 DTMAxisIterator reset()
          Resets the iterator to the last start node.
 DTMAxisIterator setStartNode(int node)
          Set context node for the iterator.
 
Methods inherited from class org.apache.xalan.xsltc.dom.MultiValuedNodeHeapIterator
addHeapNode, cloneIterator, gotoMark, setMark
 
Methods inherited from class org.apache.xml.dtm.ref.DTMAxisIteratorBase
getAxis, getPosition, getStartNode, includeSelf, isDocOrdered, isReverse, resetPosition, returnNode, setRestartable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_nodes

private IntegerArray _nodes

A reference to the key function that only has one key value or to the id function that has only one string argument can be optimized to ignore the multi-valued heap. This field will be null otherwise.


_keyValueIterator

private DTMAxisIterator _keyValueIterator

This field contains the iterator representing a node set key value argument to the key function or a node set argument to the id function.

Exactly one of this field and _keyValue must be null.


_keyValue

private java.lang.String _keyValue

This field contains the iterator representing a non-node-set key value argument to the key function or a non-node-set argument to the id function.

Exactly one of this field and _keyValueIterator must be null.


_isKeyIterator

private boolean _isKeyIterator
Indicates whether this object represents the result of a reference to the key function (true) or the id function (false).

Constructor Detail

KeyIndex.KeyIndexIterator

KeyIndex.KeyIndexIterator(java.lang.String keyValue,
                          boolean isKeyIterator)
Constructor used when the argument to key or id is not a node set.

Parameters:
keyValue - the argument to key or id cast to a String
isKeyIterator - indicates whether the constructed iterator represents a reference to key or id.

KeyIndex.KeyIndexIterator

KeyIndex.KeyIndexIterator(DTMAxisIterator keyValues,
                          boolean isKeyIterator)
Constructor used when the argument to key or id is a node set.

Parameters:
keyValues - the argument to key or id
isKeyIterator - indicates whether the constructed iterator represents a reference to key or id.
Method Detail

lookupNodes

protected IntegerArray lookupNodes(int root,
                                   java.lang.String keyValue)
Retrieve nodes for a particular key value or a particular id argument value.

Parameters:
root - The root node of the document containing the context node
keyValue - The key value of id string argument value
Returns:
an IntegerArray of the resulting nodes

setStartNode

public DTMAxisIterator setStartNode(int node)
Set context node for the iterator. This will cause the iterator to reset itself, reevaluate arguments to the function, look up nodes in the input and reinitialize its internal heap.

Specified by:
setStartNode in interface DTMAxisIterator
Overrides:
setStartNode in class MultiValuedNodeHeapIterator
Parameters:
node - the context node
Returns:
A DTMAxisIterator set to the start of the iteration.

next

public int next()
Get the next node in the iteration.

Specified by:
next in interface DTMAxisIterator
Overrides:
next in class MultiValuedNodeHeapIterator
Returns:
The next node handle in the iteration, or END.

reset

public DTMAxisIterator reset()
Resets the iterator to the last start node.

Specified by:
reset in interface DTMAxisIterator
Overrides:
reset in class MultiValuedNodeHeapIterator
Returns:
A DTMAxisIterator, which may or may not be the same as this iterator.

init

protected void init()
Evaluate the reference to the key or id function with the context specified by setStartNode(int) and set up this iterator to iterate over the DTM nodes that are to be returned.

Overrides:
init in class MultiValuedNodeHeapIterator

getLast

public int getLast()
Returns the number of nodes in this iterator.

Specified by:
getLast in interface DTMAxisIterator
Overrides:
getLast in class DTMAxisIteratorBase
Returns:
the number of nodes

getNodeByPosition

public int getNodeByPosition(int position)
Return the node at the given position.

Specified by:
getNodeByPosition in interface DTMAxisIterator
Overrides:
getNodeByPosition in class DTMAxisIteratorBase
Parameters:
position - The position
Returns:
The node at the given position.