com.waveset.util
Class BlockingQueueIterator

java.lang.Object
  extended bycom.waveset.util.BlockingQueueIterator
Direct Known Subclasses:
DoubleBufferQueue

public class BlockingQueueIterator
extends java.lang.Object

The BlockingQueueIterator emulates an Iterator, but allows WavesetException to be thrown by both nextElement() and hasMoreElements().


Nested Class Summary
static class BlockingQueueIterator.BQIData
          The BQIData class is use to wrap all data objects inserted into the queue.
 
Field Summary
static java.lang.String code_id
           
static java.lang.Object END_OF_DATA
          The END_OF_DATA object is passed in to signal that there are no more elements to be inserted in the queue
 
Constructor Summary
BlockingQueueIterator(EDU.oswego.cs.dl.util.concurrent.BoundedBuffer queue)
           
 
Method Summary
 void close()
           
protected  EDU.oswego.cs.dl.util.concurrent.BoundedBuffer getQueue()
           
 boolean hasMoreElements()
          Indicate if there are more objects in the queue
 java.lang.Object nextElement()
          Take the next object from the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

END_OF_DATA

public static final java.lang.Object END_OF_DATA
The END_OF_DATA object is passed in to signal that there are no more elements to be inserted in the queue

Constructor Detail

BlockingQueueIterator

public BlockingQueueIterator(EDU.oswego.cs.dl.util.concurrent.BoundedBuffer queue)
Method Detail

hasMoreElements

public boolean hasMoreElements()
                        throws WavesetException
Indicate if there are more objects in the queue

Returns:
true if there are more objects in the queue
Throws:
WavesetException

close

public void close()

nextElement

public java.lang.Object nextElement()
                             throws java.util.NoSuchElementException,
                                    WavesetException
Take the next object from the queue. If an exception occured in the Supplier, it is dequeued, and rethrown to the Consumer as a WavesetException. Note that this can throw NoSuchElementException, even if hasMoreElements() has returned true to the user, since another thread may have dequeued the object.

Returns:
next enqueued object
Throws:
WavesetException
java.util.NoSuchElementException

getQueue

protected EDU.oswego.cs.dl.util.concurrent.BoundedBuffer getQueue()