FileDocCategorySizeDatePackage
NodeIteratorBase.javaAPI DocJava SE 6 API4321Tue Jun 10 00:22:32 BST 2008com.sun.org.apache.xalan.internal.xsltc.dom

NodeIteratorBase

public abstract class NodeIteratorBase extends Object implements NodeIterator
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen
author
Morten Jorgensen

Fields Summary
protected int
_last
Cached computed value of last().
protected int
_position
Value of position() in this iterator. Incremented in returnNode().
protected int
_markedNode
Store node in call to setMark().
protected int
_startNode
Store node in call to setStartNode().
protected boolean
_includeSelf
Flag indicating if "self" should be returned.
protected boolean
_isRestartable
Flag indicating if iterator can be restarted.
Constructors Summary
Methods Summary
public com.sun.org.apache.xalan.internal.xsltc.NodeIteratorcloneIterator()
Clones and resets this iterator. Note that the cloned iterator is not restartable. This is because cloning is needed for variable references, and the context node of the original variable declaration must be preserved.

	try {
	    final NodeIteratorBase clone = (NodeIteratorBase)super.clone();
	    clone._isRestartable = false;
	    return clone.reset();
	}
	catch (CloneNotSupportedException e) {
	    BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
				      e.toString());
	    return null;
	}
    
public intgetLast()
Default implementation of getLast(). Stores current position and current node, resets the iterator, counts all nodes and restores iterator to original state.

	if (_last == -1) {
	    final int temp = _position;
	    setMark();
	    reset();
	    do {
		_last++;
	    } while (next() != END);
	    gotoMark();
	    _position = temp;
	}
	return _last;
    
public intgetPosition()
Returns the position() in this iterator.

	return _position == 0 ? 1 : _position;
    
public com.sun.org.apache.xalan.internal.xsltc.NodeIteratorincludeSelf()
Setter for _includeSelf flag.

	_includeSelf = true;
	return this;
    
public booleanisReverse()
Indicates if position in this iterator is computed in reverse document order. Note that nodes are always returned in document order.

	return false;
    
public com.sun.org.apache.xalan.internal.xsltc.NodeIteratorreset()
Reset this iterator using state from last call to setStartNode().

	final boolean temp = _isRestartable;
	_isRestartable = true;
	// Must adjust _startNode if self is included
	setStartNode(_includeSelf ? _startNode + 1 : _startNode);
	_isRestartable = temp;
	return this;
    
protected final com.sun.org.apache.xalan.internal.xsltc.NodeIteratorresetPosition()
Reset the position in this iterator.

	_position = 0;
	return this;
    
protected final intreturnNode(int node)
Utility method that increments position and returns its argument.

	_position++;
	return node;
    
public voidsetRestartable(boolean isRestartable)
Setter for _isRestartable flag.


              
        
	_isRestartable = isRestartable;
    
public abstract com.sun.org.apache.xalan.internal.xsltc.NodeIteratorsetStartNode(int node)
Initialize iterator using a node. If iterator is not restartable, then do nothing. If node is equal to END then subsequent calls to next() must return END.