org.apache.commons.collections
Class FilterIterator

java.lang.Object
  |
  +--org.apache.commons.collections.ProxyIterator
        |
        +--org.apache.commons.collections.FilterIterator
All Implemented Interfaces:
Iterator

public class FilterIterator
extends ProxyIterator

A Proxy Iterator which takes a Predicate instance to filter out objects from an underlying Iterator instance. Only objects for which the specified Predicate evaluates to true are returned.

Author:
James Strachan, Jan Sorensen

Constructor Summary
FilterIterator()
           
FilterIterator(Iterator iterator)
           
FilterIterator(Iterator iterator, Predicate predicate)
           
 
Method Summary
 Predicate getPredicate()
          Getter for property predicate.
 boolean hasNext()
           
 Object next()
           
 void remove()
          Always throws UnsupportedOperationException as this class does look-ahead with its internal iterator.
 void setPredicate(Predicate predicate)
          Setter for property predicate.
 
Methods inherited from class org.apache.commons.collections.ProxyIterator
getIterator, setIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterIterator

public FilterIterator()

FilterIterator

public FilterIterator(Iterator iterator)

FilterIterator

public FilterIterator(Iterator iterator,
                      Predicate predicate)
Method Detail

getPredicate

public Predicate getPredicate()
Getter for property predicate.
Returns:
Value of property predicate.

hasNext

public boolean hasNext()
Overrides:
hasNext in class ProxyIterator
Returns:
true if there is another object that matches the given predicate

next

public Object next()
Overrides:
next in class ProxyIterator
Returns:
the next object which matches the given predicate

remove

public void remove()
Always throws UnsupportedOperationException as this class does look-ahead with its internal iterator.
Overrides:
remove in class ProxyIterator

setPredicate

public void setPredicate(Predicate predicate)
Setter for property predicate.
Parameters:
predicate - New value of property predicate.


Copyright © 2001 Apache Software Foundation. Documenation generated April 2 2002.