net.sourceforge.nite.util
Class IteratorTransformFilter

java.lang.Object
  extended by net.sourceforge.nite.util.IteratorTransformFilter
All Implemented Interfaces:
java.util.Iterator

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

An IteratorTransform is used to transform Objects in an Iterator and present them as a new Iterator. The difference with a normal IteratorTransform is that this implementation will not throw exceptions when the transformation fails but rather will act as a filter for those objects, passing on only those objects in the original iterator on which the transformation can be successfully applied.

I.e., the function hasNext will return true if the original iterator has no next object that can be transformed.

NB: This is a VERY expensive iterator when there are many objects that cannot be transformed, due to all the exceptions that will be thrown.

Author:
Dennis Reidsma, UTwente
Adapted from the parlevink package (HMI group, University of Twente)

Constructor Summary
IteratorTransformFilter(java.util.Iterator it, Transform trans)
           
 
Method Summary
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorTransformFilter

public IteratorTransformFilter(java.util.Iterator it,
                               Transform trans)
Parameters:
it - The Iterator to filter
trans - The Transformation
Method Detail

remove

public void remove()
Specified by:
remove in interface java.util.Iterator
Throws:
java.lang.UnsupportedOperationException

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator