net.sf.morph.transform.support
Class ResetableIteratorWrapper

java.lang.Object
  extended by net.sf.morph.transform.support.ResetableIteratorWrapper
All Implemented Interfaces:
java.util.Iterator

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

Reads the contents of an Iterator and saves them so that the Iterator can be iterated over multiple times.

Since:
Dec 5, 2004
Author:
Matt Sgarlata

Constructor Summary
ResetableIteratorWrapper()
           
ResetableIteratorWrapper(java.util.Iterator iterator)
           
 
Method Summary
 java.util.Iterator getIterator()
          Returns a fresh copy of the wrapped iterator that is ready for another iteration.
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
           
 void reset()
           
 void setIterator(java.util.Iterator iterator)
          Sets the delegate iterator for this wrapper.
 int size()
          Get the size of the underlying Iterator.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResetableIteratorWrapper

public ResetableIteratorWrapper()

ResetableIteratorWrapper

public ResetableIteratorWrapper(java.util.Iterator iterator)
Method Detail

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

remove

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

reset

public void reset()

getIterator

public java.util.Iterator getIterator()
Returns a fresh copy of the wrapped iterator that is ready for another iteration.

Returns:
null if the delegate iterator was never set

setIterator

public void setIterator(java.util.Iterator iterator)
Sets the delegate iterator for this wrapper.

Parameters:
iterator - the Iterator to set
Throws:
java.lang.IllegalStateException - if the iterator has already been set
java.lang.IllegalArgumentException - if the iterator is null

size

public int size()
Get the size of the underlying Iterator.

Returns:
int

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2008.