org.apache.xml.dtm.ref
Class DTMDefaultBaseIterators.ParentIterator

java.lang.Object
  extended byorg.apache.xml.dtm.ref.DTMAxisIteratorBase
      extended byorg.apache.xml.dtm.ref.DTMDefaultBaseIterators.InternalAxisIteratorBase
          extended byorg.apache.xml.dtm.ref.DTMDefaultBaseIterators.ParentIterator
All Implemented Interfaces:
Cloneable, DTMAxisIterator
Enclosing class:
DTMDefaultBaseIterators

private final class DTMDefaultBaseIterators.ParentIterator
extends DTMDefaultBaseIterators.InternalAxisIteratorBase

Iterator that returns the parent of a given node. Note that this delivers only a single node; if you want all the ancestors, see AncestorIterator.


Field Summary
protected  int _currentNode
          Current iteration location.
private  int _nodeType
          The extended type ID that was requested.
 
Fields inherited from class org.apache.xml.dtm.ref.DTMAxisIteratorBase
_includeSelf, _isRestartable, _markedNode, _startNode
 
Fields inherited from interface org.apache.xml.dtm.DTMAxisIterator
END
 
Constructor Summary
private DTMDefaultBaseIterators.ParentIterator()
           
 
Method Summary
 void gotoMark()
          Restores the current node remembered by setMark().
 int next()
          Get the next node in the iteration.
 void setMark()
          Remembers the current node for the next call to gotoMark().
 DTMAxisIterator setNodeType(int type)
          Set the node type of the parent that we're looking for.
 DTMAxisIterator setStartNode(int node)
          Set start to END should 'close' the iterator, i.e. subsequent call to next() should return END.
 
Methods inherited from class org.apache.xml.dtm.ref.DTMAxisIteratorBase
cloneIterator, getAxis, getLast, getPosition, getStartNode, includeSelf, isDocOrdered, isReverse, reset, resetPosition, returnNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_nodeType

private int _nodeType
The extended type ID that was requested.


_currentNode

protected int _currentNode
Current iteration location. Usually this is the last location returned (starting point for the next() search); for single-node iterators it may instead be initialized to point to that single node.

Constructor Detail

DTMDefaultBaseIterators.ParentIterator

private DTMDefaultBaseIterators.ParentIterator()
Method Detail

setStartNode

public DTMAxisIterator setStartNode(int node)
Set start to END should 'close' the iterator, i.e. subsequent call to next() should return END.

Parameters:
node - Sets the root of the iteration.
Returns:
A DTMAxisIterator set to the start of the iteration.

setNodeType

public DTMAxisIterator setNodeType(int type)
Set the node type of the parent that we're looking for. Note that this does _not_ mean "find the nearest ancestor of this type", but "yield the parent if it is of this type".

Parameters:
type - extended type ID.
Returns:
ParentIterator configured with the type filter set.

next

public int next()
Get the next node in the iteration. In this case, we return only the immediate parent, _if_ it matches the requested nodeType.

Returns:
The next node handle in the iteration, or END.

setMark

public void setMark()
Remembers the current node for the next call to gotoMark(). %REVIEW% Should this save _position too?


gotoMark

public void gotoMark()
Restores the current node remembered by setMark(). %REVEIW% Should this restore _position too?