org.apache.commons.collections.iterators
Class FilterIterator
java.lang.Object
org.apache.commons.collections.iterators.FilterIterator
- Iterator
public class FilterIterator
extends java.lang.Object
implements Iterator
Decorates an iterator such that only elements matching a predicate filter
are returned.
$Revision: 1.8 $ $Date: 2004/02/18 00:59:50 $- James Strachan
- Jan Sorensen
- Ralph Wagner
- Stephen Colebourne
Iterator | getIterator() - Gets the iterator this iterator is using.
|
Predicate | getPredicate() - Gets the predicate this iterator is using.
|
boolean | hasNext() - Returns true if the underlying iterator contains an object that
matches the predicate.
|
Object | next() - Returns the next object that matches the predicate.
|
void | remove() - Removes from the underlying collection of the base iterator the last
element returned by this iterator.
|
void | setIterator(Iterator iterator) - Sets the iterator for this iterator to use.
|
void | setPredicate(Predicate predicate) - Sets the predicate this the iterator to use.
|
FilterIterator
public FilterIterator()
Constructs a new
FilterIterator
that will not function
until
setIterator
is invoked.
FilterIterator
public FilterIterator(Iterator iterator)
Constructs a new
FilterIterator
that will not function
until
setPredicate
is invoked.
iterator
- the iterator to use
FilterIterator
public FilterIterator(Iterator iterator,
Predicate predicate)
Constructs a new FilterIterator
that will use the
given iterator and predicate.
iterator
- the iterator to usepredicate
- the predicate to use
getIterator
public Iterator getIterator()
Gets the iterator this iterator is using.
getPredicate
public Predicate getPredicate()
Gets the predicate this iterator is using.
hasNext
public boolean hasNext()
Returns true if the underlying iterator contains an object that
matches the predicate.
- true if there is another object that matches the predicate
next
public Object next()
Returns the next object that matches the predicate.
- the next object which matches the given predicate
remove
public void remove()
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.
setIterator
public void setIterator(Iterator iterator)
Sets the iterator for this iterator to use.
If iteration has started, this effectively resets the iterator.
iterator
- the iterator to use
setPredicate
public void setPredicate(Predicate predicate)
Sets the predicate this the iterator to use.
predicate
- the transformer to use
Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.