edu.mit.jverbnet.util
Class FilteringIterator<E>

java.lang.Object
  extended by edu.mit.jverbnet.util.FilteringIterator<E>
All Implemented Interfaces:
java.util.Iterator<E>

public abstract class FilteringIterator<E>
extends java.lang.Object
implements java.util.Iterator<E>

An iterator that filters the output of another iterator. This implementation does not support the remove() method; if that method is called it throws UnsupportedOperationException.

Since:
JVerbnet 1.0.0
Version:
1.2.0
Author:
Mark A. Finlayson

Constructor Summary
FilteringIterator(java.util.Iterator<E> backingItr)
          Creates a new filtering iterator that uses the specified iterator to supply its elements.
 
Method Summary
protected  void advance()
          Finds the next valid element from the backing iterator.
 boolean hasNext()
           
protected abstract  boolean include(E element)
          Returns true if the specified element should be returned by the filtering iterator; false if the element should be filtered.
 E next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteringIterator

public FilteringIterator(java.util.Iterator<E> backingItr)
Creates a new filtering iterator that uses the specified iterator to supply its elements.

Parameters:
backingItr - the iterator from which the filtering iterator gets its elements; may not be null
Throws:
java.lang.NullPointerException - if the specified iterator is null
Since:
JVerbnet 1.0.0
Method Detail

advance

protected void advance()
Finds the next valid element from the backing iterator.

Since:
JVerbnet 1.0.0

include

protected abstract boolean include(E element)
Returns true if the specified element should be returned by the filtering iterator; false if the element should be filtered.

Parameters:
element - the item to be checked
Since:
JVerbnet 1.0.0

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<E>

next

public E next()
Specified by:
next in interface java.util.Iterator<E>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<E>


Copyright © 2012 ${project.organization.name}. All Rights Reserved.