Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Util.Collections
Class FilterIterator  view FilterIterator download FilterIterator.java

java.lang.Object
  extended byUtil.Collections.UnmodifiableIterator
      extended byUtil.Collections.FilterIterator
All Implemented Interfaces:
java.util.Iterator

public class FilterIterator
extends UnmodifiableIterator
implements java.util.Iterator

A FilterIterator filters and maps a source Iterator to generate a new one. Note that this implementation reads one element ahead, so if the Filter changes for an object 'o' between the time that is read (when next() is called, returning the object preceding 'o', and checking that 'o' satisfies the current Filter) and the time when hasNext() is called, 'o' will still be returned, regardless of what Filter.isElement(o) returns. Thus, it is recommended that only Filters which remain consistent throughout the iteration be used.

Version:
$Id: FilterIterator.java,v 1.1 2003/03/05 08:26:27 joewhaley Exp $

Nested Class Summary
static class FilterIterator.Filter
           
 
Field Summary
private  boolean done
           
(package private)  FilterIterator.Filter f
           
(package private)  java.util.Iterator i
           
private  java.lang.Object next
           
 
Constructor Summary
FilterIterator(java.util.Iterator i, FilterIterator.Filter f)
          Creates a FilterIterator.
 
Method Summary
private  void advance()
           
 boolean hasNext()
          Tests whether there are elements remaining in the collection.
 java.lang.Object next()
          Obtain the next element in the collection.
 
Methods inherited from class Util.Collections.UnmodifiableIterator
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Iterator
remove
 

Field Detail

i

java.util.Iterator i

f

FilterIterator.Filter f

next

private java.lang.Object next

done

private boolean done
Constructor Detail

FilterIterator

public FilterIterator(java.util.Iterator i,
                      FilterIterator.Filter f)
Creates a FilterIterator.

Method Detail

advance

private void advance()

next

public java.lang.Object next()
Description copied from interface: java.util.Iterator
Obtain the next element in the collection.

Specified by:
next in interface java.util.Iterator
Specified by:
next in class UnmodifiableIterator

hasNext

public boolean hasNext()
Description copied from interface: java.util.Iterator
Tests whether there are elements remaining in the collection. In other words, calling next() will not throw an exception.

Specified by:
hasNext in interface java.util.Iterator
Specified by:
hasNext in class UnmodifiableIterator