| |
|
| java.lang.Object org.apache.commons.collections.iterators.FilterIterator
All known Subclasses: org.apache.commons.collections.iterators.UniqueFilterIterator,
FilterIterator | public class FilterIterator implements Iterator(Code) | | Decorates another
Iterator using a predicate to filter elements.
This iterator decorates the underlying iterator, only allowing through
those elements that match the specified
Predicate Predicate .
since: Commons Collections 1.0 version: $Revision: 366576 $ $Date: 2006-01-06 22:07:07 +0000 (Fri, 06 Jan 2006) $ author: James Strachan author: Jan Sorensen author: Ralph Wagner author: Stephen Colebourne |
Method Summary | |
public Iterator | getIterator() Gets the iterator this iterator is using. | public Predicate | getPredicate() Gets the predicate this iterator is using. | public boolean | hasNext() Returns true if the underlying iterator contains an object that
matches the predicate. | public Object | next() Returns the next object that matches the predicate. | public void | remove() Removes from the underlying collection of the base iterator the last
element returned by this iterator. | public void | setIterator(Iterator iterator) Sets the iterator for this iterator to use. | public void | setPredicate(Predicate predicate) Sets the predicate this the iterator to use. |
FilterIterator | public FilterIterator(Iterator iterator, Predicate predicate)(Code) | | Constructs a new FilterIterator that will use the
given iterator and predicate.
Parameters: iterator - the iterator to use Parameters: predicate - the predicate to use |
getIterator | public Iterator getIterator()(Code) | | Gets the iterator this iterator is using.
the iterator |
getPredicate | public Predicate getPredicate()(Code) | | Gets the predicate this iterator is using.
the predicate |
hasNext | public boolean hasNext()(Code) | | Returns true if the underlying iterator contains an object that
matches the predicate.
true if there is another object that matches the predicate throws: NullPointerException - if either the iterator or predicate are null |
next | public Object next()(Code) | | Returns the next object that matches the predicate.
the next object which matches the given predicate throws: NullPointerException - if either the iterator or predicate are null throws: NoSuchElementException - if there are no more elements thatmatch the predicate |
remove | public void remove()(Code) | | Removes from the underlying collection of the base iterator the last
element returned by this iterator.
This method can only be called
if next() was called, but not after
hasNext() , because the hasNext() call
changes the base iterator.
throws: IllegalStateException - if hasNext() has alreadybeen called. |
setIterator | public void setIterator(Iterator iterator)(Code) | | Sets the iterator for this iterator to use.
If iteration has started, this effectively resets the iterator.
Parameters: iterator - the iterator to use |
setPredicate | public void setPredicate(Predicate predicate)(Code) | | Sets the predicate this the iterator to use.
Parameters: predicate - the predicate to use |
|
|
|