ca.uhn.cache.util
Class MutableIterator

java.lang.Object
  extended byca.uhn.cache.util.MutableIterator
All Implemented Interfaces:
IMutableIterator, java.util.Iterator
Direct Known Subclasses:
MutableMergeableIterator

public class MutableIterator
extends java.lang.Object
implements IMutableIterator

Default implementation of IMutableIterator. The default close() method does nothing, and should be overridden to perform any required cleanup. Note that this class is NOT thread-safe in the sense of supporting multiple iterating clients or competing threads calling add and freeze (although different threads may add and iterate concurrently). It is assumed that one thread is iterating. It is up to the caller to ensure that freeze() is not called until after add() has been called as for the last time.

Version:
$Revision: 1.1 $ updated on $Date: 2005/01/26 00:25:50 $ by $Author: bryan_tripp $
Author:
Bryan Tripp

Constructor Summary
MutableIterator()
          New instance.
 
Method Summary
 void add(java.lang.Object theObject)
          Adds a single item to the list which this iterator iterates through.
 void close()
          Does nothing by default.
 void declareException(java.lang.Exception theException)
          This indicates that an exception has been encountered while populating this iterator.
 void freeze()
          Called after all add() and merge() calls.
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MutableIterator

public MutableIterator()
New instance.

Method Detail

add

public void add(java.lang.Object theObject)
Description copied from interface: IMutableIterator
Adds a single item to the list which this iterator iterates through.

Specified by:
add in interface IMutableIterator
Parameters:
theObject - IDataItem to add
See Also:
ca.uhn.cache.IMutableIterator#add(java.lang.Object)

freeze

public void freeze()
Description copied from interface: IMutableIterator
Called after all add() and merge() calls. The add() and merge() methods may not be called after this. This method MUST be called when additions are complete, or else hasNext() will pend indefinitely. This is because if further additions are possible, hasNext() is undefined.

Specified by:
freeze in interface IMutableIterator
See Also:
ca.uhn.cache.IMutableIterator#freeze()

hasNext

public boolean hasNext()
                throws MutableIteratorException
Specified by:
hasNext in interface java.util.Iterator
Throws:
MutableIteratorException
See Also:
java.util.Iterator.hasNext()

next

public java.lang.Object next()
                      throws MutableIteratorException,
                             java.util.NoSuchElementException
Specified by:
next in interface java.util.Iterator
Throws:
MutableIteratorException
java.util.NoSuchElementException
See Also:
Iterator.next()

close

public void close()
Does nothing by default. Override if you need to do more.

Specified by:
close in interface IMutableIterator
See Also:
ca.uhn.cache.IMutableIterator#close()

declareException

public void declareException(java.lang.Exception theException)
Description copied from interface: IMutableIterator
This indicates that an exception has been encountered while populating this iterator. A MutableIteratorException wrapping this one will be thrown on the next call to next().

Specified by:
declareException in interface IMutableIterator
Parameters:
theException - exception to declare
See Also:
ca.uhn.cache.IMutableIterator#declareException(java.lang.Exception)

remove

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


Copyright © 2004-2005 University Health Network. All Rights Reserved.