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

FilterIterator

public final class FilterIterator extends DTMAxisIteratorBase
Similar to a CurrentNodeListIterator except that the filter has a simpler interface (only needs the node, no position, last, etc.) It takes a source iterator and a Filter object and returns nodes from the source after filtering them by calling filter.test(node).
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
private DTMAxisIterator
_source
Reference to source iterator.
private final DTMFilter
_filter
Reference to a filter object that to be applied to each node.
private final boolean
_isReverse
A flag indicating if position is reversed.
Constructors Summary
public FilterIterator(DTMAxisIterator source, DTMFilter filter)

	_source = source;
// System.out.println("FI souce = " + source + " this = " + this);
	_filter = filter;
	_isReverse = source.isReverse();
    
Methods Summary
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorcloneIterator()


	try {
	    final FilterIterator clone = (FilterIterator) 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 booleanisReverse()

	return _isReverse;
    
public intnext()

	int node;
	while ((node = _source.next()) != END) {
	    if (_filter.acceptNode(node, DTMFilter.SHOW_ALL) == DTMIterator.FILTER_ACCEPT) {
		return returnNode(node);
	    }
	}
	return END;
    
public com.sun.org.apache.xml.internal.dtm.DTMAxisIteratorreset()

	_source.reset();
	return resetPosition();
    
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(_startNode = node); 
	    return resetPosition();
	}
	return this;