com.hp.hpl.jena.util.iterator
Class FilterIterator<T>

java.lang.Object
  extended by com.hp.hpl.jena.util.iterator.NiceIterator<T>
      extended by com.hp.hpl.jena.util.iterator.WrappedIterator<T>
          extended by com.hp.hpl.jena.util.iterator.FilterIterator<T>
All Implemented Interfaces:
ClosableIterator<T>, ExtendedIterator<T>, java.util.Iterator<T>
Direct Known Subclasses:
FilterDropIterator, FilterKeepIterator

public class FilterIterator<T>
extends WrappedIterator<T>

Creates a sub-Iterator by filtering. This class should not be used directly any more; the subclasses FilterKeepIterator and FilterDropIterator should be used instead.

Author:
jjc, mods [clarity & speedup] by kers

Constructor Summary
FilterIterator(Filter<T> fl, java.util.Iterator<T> e)
          Initialises a FilterIterator with its filter and base.
 
Method Summary
 boolean hasNext()
          Answer true iff there is at least one more acceptable object.
 T next()
          Answer the next acceptable object from the base iterator.
 void remove()
          Remove the current member from the underlying iterator.
 
Methods inherited from class com.hp.hpl.jena.util.iterator.WrappedIterator
close, close, create, createNoRemove, forTestingOnly_getBase
 
Methods inherited from class com.hp.hpl.jena.util.iterator.NiceIterator
andThen, andThen, asList, asSet, emptyIterator, filterDrop, filterKeep, mapWith, removeNext, toList, toSet
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterIterator

public FilterIterator(Filter<T> fl,
                      java.util.Iterator<T> e)
Initialises a FilterIterator with its filter and base.

Parameters:
fl - An object is included if it is accepted by this Filter.
e - The base Iterator.
Method Detail

hasNext

public boolean hasNext()
Answer true iff there is at least one more acceptable object. [Stores reference into current, sets canRemove false; answer preserved in `hasCurrent`]

Specified by:
hasNext in interface java.util.Iterator<T>
Overrides:
hasNext in class WrappedIterator<T>

remove

public void remove()
Remove the current member from the underlying iterator. Legal only after a .next() but before any subsequent .hasNext(), because that may advance the underlying iterator.

Specified by:
remove in interface java.util.Iterator<T>
Overrides:
remove in class WrappedIterator<T>

next

public T next()
Answer the next acceptable object from the base iterator. The redundant test of `hasCurrent` appears to make a detectable speed difference. Crazy.

Specified by:
next in interface java.util.Iterator<T>
Overrides:
next in class WrappedIterator<T>


Copyright ? 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP