gshute.util
Class ConvertedIterator

java.lang.Object
  |
  +--gshute.util.ConvertedIterator

public class ConvertedIterator
extends java.lang.Object
implements java.util.Iterator

A ConvertedIterator is an iterator that converts the items in a base iterator. The conversion is performed by an item converter that is specified by a parameter in the constructor. The iteration sequence of a converted iterator consists of converted items in the base iteration sequence.


Field Summary
protected  java.util.Iterator baseIterator
          baseIterator is the base iterator.
protected  Converter converter
          converter is the item converter.
 
Constructor Summary
ConvertedIterator(java.util.Collection c, Converter cvtr)
          new ConvertedIterator(c, cvtr) returns a new converted iterator whose base iterator is a default iterator for c and whose converter is cvtr.
ConvertedIterator(java.util.Iterator baseIt, Converter cvtr)
          new ConvertedIterator(baseIt, cvtr) returns a new converted iterator whose base iterator is baseIt and whose converter is cvtr.
 
Method Summary
 boolean hasNext()
          iter.hasNext() returns true if there is another object in iter.
 java.lang.Object next()
          iter.next() returns the next object in iter and advances iter.
 void remove()
          iter.remove() removes the last object returned by iter.next() from its underlying collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseIterator

protected java.util.Iterator baseIterator
baseIterator is the base iterator.

converter

protected Converter converter
converter is the item converter.
Constructor Detail

ConvertedIterator

public ConvertedIterator(java.util.Collection c,
                         Converter cvtr)
new ConvertedIterator(c, cvtr) returns a new converted iterator whose base iterator is a default iterator for c and whose converter is cvtr.

ConvertedIterator

public ConvertedIterator(java.util.Iterator baseIt,
                         Converter cvtr)
new ConvertedIterator(baseIt, cvtr) returns a new converted iterator whose base iterator is baseIt and whose converter is cvtr.
Method Detail

hasNext

public boolean hasNext()
iter.hasNext() returns true if there is another object in iter.
Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
iter.next() returns the next object in iter and advances iter.
Specified by:
next in interface java.util.Iterator

remove

public void remove()
iter.remove() removes the last object returned by iter.next() from its underlying collection. This operation is supported by a converted iterator only if it is supported by its base iterator.
Specified by:
remove in interface java.util.Iterator