org.elkoserver.util
Class ExcludingIterator<V>

java.lang.Object
  extended by org.elkoserver.util.ExcludingIterator<V>
All Implemented Interfaces:
Iterator<V>

public abstract class ExcludingIterator<V>
extends Object
implements Iterator<V>

Iterator over a collection that excludes a distinguished element.


Constructor Summary
ExcludingIterator(Iterator<V> base)
          Constructor.
 
Method Summary
 boolean hasNext()
          Returns true if the iteration has more elements.
abstract  boolean isExcluded(V element)
          Test if a given element should be excluded from the iteration.
 V 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

ExcludingIterator

public ExcludingIterator(Iterator<V> base)
Constructor.

Parameters:
base - The underlying iterator.
exclusion - The distinguished element to exclude.
Method Detail

isExcluded

public abstract boolean isExcluded(V element)
Test if a given element should be excluded from the iteration. Sub-classes implement this.

Parameters:
element - The element to be tested.
Returns:
true if the element should be excluded from the iteration, false if if should be included.

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<V>
Returns:
true if the iterator has more elements.

next

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

Specified by:
next in interface Iterator<V>
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<V>
Throws:
UnsupportedOperationException - always.