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

NthIterator

public final class NthIterator extends DTMAxisIteratorBase
author
Jacek Ambroziak
author
Morten Jorgensen

Fields Summary
private DTMAxisIterator
_source
private final int
_position
private boolean
_ready
Constructors Summary
public NthIterator(DTMAxisIterator source, int n)

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

	try {
	    final NthIterator clone = (NthIterator) super.clone();
	    clone._source = _source.cloneIterator();	// resets source
	    clone._isRestartable = false;
	    return clone;
	}
	catch (CloneNotSupportedException e) {
	    BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
				      e.toString());
	    return null;
	}
    
public intgetLast()

	return 1;
    
public intgetPosition()

	return 1;
    
public voidgotoMark()

	_source.gotoMark();
    
public intnext()

	if (_ready) {
	    _ready = false;
	    return _source.getNodeByPosition(_position);
	}
	return DTMAxisIterator.END;
	/*
	if (_ready && _position > 0) {
            final int pos = _source.isReverse()
                                       ? _source.getLast() - _position + 1
                                       : _position;

	    _ready = false;
	    int node;
	    while ((node = _source.next()) != DTMAxisIterator.END) {
		if (pos == _source.getPosition()) {
		    return node;
		}
	    }
	}
	return DTMAxisIterator.END;
	*/
    
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorreset()

	_source.reset();
	_ready = true;
	return this;
    
public voidsetMark()

	_source.setMark();
    
public voidsetRestartable(boolean isRestartable)

	_isRestartable = isRestartable;
	_source.setRestartable(isRestartable);
    
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorsetStartNode(int node)

	if (_isRestartable) {
	    _source.setStartNode(node);
	    _ready = true;
	}
	return this;