org.elkoserver.util
Class FilteringIterator<From,To>

java.lang.Object
  extended by org.elkoserver.util.FilteringIterator<From,To>
All Implemented Interfaces:
Iterator<To>

public class FilteringIterator<From,To>
extends Object
implements Iterator<To>

Iterator that takes an iterator producing values of one type and generates values of another type via a transformation method that is supplied by the implementing subclass.


Nested Class Summary
static interface FilteringIterator.Filter<From,To>
          Utility class implemented by filters used by the FilteringIterator iterator class.
 
Constructor Summary
FilteringIterator(Iterator<From> base, FilteringIterator.Filter<From,To> filter)
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more elements.
 To next()
          Returns the next element in the iteration.
 void remove()
          This operation is not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteringIterator

public FilteringIterator(Iterator<From> base,
                         FilteringIterator.Filter<From,To> filter)
Constructor.

Parameters:
base - The iterator whose elements are to be transformed.
filter - The filter to transform the iterata.
Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next() would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator<To>
Returns:
true if the iterator has more elements.

next

public To next()
Returns the next element in the iteration.

Specified by:
next in interface Iterator<To>
Returns:
the next element in the iteration.
Throws:
NoSuchElementException - iteration has no more elements.

remove

public void remove()
This operation is not supported.

Specified by:
remove in interface Iterator<To>
Throws:
UnsupportedOperationException - always.