org.apache.commons.collections15.iterators
Class FilterListIterator<E>

java.lang.Object
  extended by org.apache.commons.collections15.iterators.FilterListIterator<E>
All Implemented Interfaces:
Iterator<E>, ListIterator<E>

public class FilterListIterator<E>
extends Object
implements ListIterator<E>

A proxy ListIterator which takes a Predicate instance to filter out objects from an underlying ListIterator instance. Only objects for which the specified Predicate evaluates to true are returned by the iterator.

Since:
Commons Collections 2.0
Version:
$Revision: 1.1 $ $Date: 2005/10/11 17:05:24 $
Author:
Matt Hall, John Watkinson, Rodney Waldhoff

Constructor Summary
FilterListIterator()
          Constructs a new FilterListIterator that will not function until setPredicate is invoked.
FilterListIterator(ListIterator<E> iterator)
          Constructs a new FilterListIterator that will not function until setPredicate is invoked.
FilterListIterator(ListIterator<E> iterator, Predicate<? super E> predicate)
          Constructs a new FilterListIterator.
FilterListIterator(Predicate<? super E> predicate)
          Constructs a new FilterListIterator.
 
Method Summary
 void add(E o)
          Not supported.
 ListIterator<E> getListIterator()
          Gets the iterator this iterator is using.
 Predicate<? super E> getPredicate()
          Gets the predicate this iterator is using.
 boolean hasNext()
           
 boolean hasPrevious()
           
 E next()
           
 int nextIndex()
           
 E previous()
           
 int previousIndex()
           
 void remove()
          Not supported.
 void set(E o)
          Not supported.
 void setListIterator(ListIterator<E> iterator)
          Sets the iterator for this iterator to use.
 void setPredicate(Predicate<? super E> predicate)
          Sets the predicate this the iterator to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterListIterator

public FilterListIterator()
Constructs a new FilterListIterator that will not function until setPredicate is invoked.


FilterListIterator

public FilterListIterator(ListIterator<E> iterator)
Constructs a new FilterListIterator that will not function until setPredicate is invoked.

Parameters:
iterator - the iterator to use

FilterListIterator

public FilterListIterator(ListIterator<E> iterator,
                          Predicate<? super E> predicate)
Constructs a new FilterListIterator.

Parameters:
iterator - the iterator to use
predicate - the predicate to use

FilterListIterator

public FilterListIterator(Predicate<? super E> predicate)
Constructs a new FilterListIterator.

Parameters:
predicate - the predicate to use.
Method Detail

add

public void add(E o)
Not supported.

Specified by:
add in interface ListIterator<E>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>
Specified by:
hasNext in interface ListIterator<E>

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface ListIterator<E>

next

public E next()
Specified by:
next in interface Iterator<E>
Specified by:
next in interface ListIterator<E>

nextIndex

public int nextIndex()
Specified by:
nextIndex in interface ListIterator<E>

previous

public E previous()
Specified by:
previous in interface ListIterator<E>

previousIndex

public int previousIndex()
Specified by:
previousIndex in interface ListIterator<E>

remove

public void remove()
Not supported.

Specified by:
remove in interface Iterator<E>
Specified by:
remove in interface ListIterator<E>

set

public void set(E o)
Not supported.

Specified by:
set in interface ListIterator<E>

getListIterator

public ListIterator<E> getListIterator()
Gets the iterator this iterator is using.

Returns:
the iterator.

setListIterator

public void setListIterator(ListIterator<E> iterator)
Sets the iterator for this iterator to use. If iteration has started, this effectively resets the iterator.

Parameters:
iterator - the iterator to use

getPredicate

public Predicate<? super E> getPredicate()
Gets the predicate this iterator is using.

Returns:
the predicate.

setPredicate

public void setPredicate(Predicate<? super E> predicate)
Sets the predicate this the iterator to use.

Parameters:
predicate - the transformer to use


Copyright © 2001-2010 Apache Software Foundation. All Rights Reserved.