org.archive.util.iterator
Class TransformingIteratorWrapper<Original,Transformed>

java.lang.Object
  extended by org.archive.util.iterator.LookaheadIterator<Transformed>
      extended by org.archive.util.iterator.TransformingIteratorWrapper<Original,Transformed>
All Implemented Interfaces:
java.util.Iterator<Transformed>
Direct Known Subclasses:
RegexpLineIterator, SeedFileIterator

public abstract class TransformingIteratorWrapper<Original,Transformed>
extends LookaheadIterator<Transformed>

Superclass for Iterators which transform and/or filter results from a wrapped Iterator. Because transform() has the option of discarding an item from the inner Iterator (by returning null), this is a kind of LookaheadIterator.

Author:
gojomo

Field Summary
protected  java.util.Iterator<Original> inner
           
 
Fields inherited from class org.archive.util.iterator.LookaheadIterator
next
 
Constructor Summary
TransformingIteratorWrapper()
           
 
Method Summary
protected  boolean lookahead()
          Caches the next item if available.
protected  void noteExhausted()
          Any cleanup to occur when hasNext() is about to return false
protected abstract  Transformed transform(Original object)
           
 
Methods inherited from class org.archive.util.iterator.LookaheadIterator
hasNext, next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inner

protected java.util.Iterator<Original> inner
Constructor Detail

TransformingIteratorWrapper

public TransformingIteratorWrapper()
Method Detail

lookahead

protected boolean lookahead()
Description copied from class: LookaheadIterator
Caches the next item if available.

Specified by:
lookahead in class LookaheadIterator<Transformed>
Returns:
true if there was a next item to cache, false otherwise

noteExhausted

protected void noteExhausted()
Any cleanup to occur when hasNext() is about to return false


transform

protected abstract Transformed transform(Original object)
Parameters:
object - Object to transform.
Returns:
Transfomed object.


Copyright © 2003-2011 Internet Archive. All Rights Reserved.