FileDocCategorySizeDatePackage
ForwardPositionIterator.javaAPI DocJava SE 5 API3367Fri Aug 26 14:55:40 BST 2005com.sun.org.apache.xalan.internal.xsltc.dom

ForwardPositionIterator

public final class ForwardPositionIterator extends DTMAxisIteratorBase
This iterator is a wrapper that always returns the position of a node in document order. It is needed for the case where a call to position() occurs in the context of an XSLT element such as xsl:for-each, xsl:apply-templates, etc. The getPosition() methods in DTMAxisIterators defined in DTMDefaultBaseIterators always return the position in document order, which is backwards for XPath in the case of the ancestor, ancestor-or-self, previous and previous-sibling. XSLTC implements position() with the BasisLibrary.positionF() method, and uses the DTMAxisIterator.isReverse() method to determine whether the result of getPosition() should be interpreted as being equal to position(). But when the expression appears in apply-templates of for-each, the position() function operates in document order. The only effect of the ForwardPositionIterator is to force the result of isReverse() to false, so that BasisLibrary.positionF() calculates position() in a way that's consistent with the context in which the iterator is being used." (Apparently the correction of isReverse() occurs implicitly, by inheritance. This class also appears to maintain its own position counter, which seems redundant.)
deprecated
This class exists only for backwards compatibility with old translets. New code should not reference it.

Fields Summary
private DTMAxisIterator
_source
Constructors Summary
public ForwardPositionIterator(DTMAxisIterator source)

	_source = source;
    
Methods Summary
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorcloneIterator()

	try {
	    final ForwardPositionIterator clone = 
		(ForwardPositionIterator) super.clone();
	    clone._source = _source.cloneIterator();
	    clone._isRestartable = false;
	    return clone.reset();
	}
	catch (CloneNotSupportedException e) {
	    BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
				      e.toString());
	    return null;
	}
    
public voidgotoMark()

	_source.gotoMark();
    
public intnext()

	return returnNode(_source.next());
    
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorreset()

	_source.reset();
	return resetPosition();
    
public voidsetMark()

	_source.setMark();
    
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorsetStartNode(int node)

	_source.setStartNode(node);
	return this;