|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.IteratorQueue<T>
public class IteratorQueue<T>
a special iterator that supplies elements from an embedded blocking queue and blocks
on calls to hasNext().
This class is particularly handy if you want to supply data through an iterator
from a different thread than from where it is read.
The next() method only returns false after
the close() method is called and the queue is empty.
| Constructor Summary | |
|---|---|
IteratorQueue(Collection<? extends T> collection)
|
|
IteratorQueue(T... elements)
|
|
| Method Summary | |
|---|---|
void |
add(T element)
|
int |
available()
a non-blocking call to see how many elements are currently available in this queue |
void |
clearException()
|
void |
close()
|
int |
getCounter()
|
Throwable |
getException()
|
T |
getRelevantValue()
returns the relevant value for this instance at the time of calling |
boolean |
hasMoreElements()
|
boolean |
hasNext()
|
boolean |
isClosed()
|
Iterator<T> |
iterator()
|
T |
next()
|
T |
nextElement()
|
void |
remove()
|
void |
setException(String msg)
throws an exception to the caller of hasNext() |
void |
setException(Throwable exception)
throws an exception to the caller of hasNext() |
Queue<T> |
unwrap()
returns the embedded instance that this wrapper encloses |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IteratorQueue(T... elements)
public IteratorQueue(Collection<? extends T> collection)
| Method Detail |
|---|
public Queue<T> unwrap()
Wrapped
unwrap in interface Wrapped<Queue<T>>
public void add(T element)
throws IllegalStateException
IllegalStateExceptionpublic void setException(String msg)
hasNext()
public void setException(Throwable exception)
hasNext()
public Throwable getException()
public void clearException()
public int available()
public int getCounter()
public T getRelevantValue()
throws IOException
ValueRetriever
getRelevantValue in interface ValueRetriever<T>IOException - if any resource to fulfill the request is not accessible
public boolean hasNext()
throws IterationException
hasNext in interface Iterator<T>IterationExceptionpublic T next()
next in interface Iterator<T>public void remove()
remove in interface Iterator<T>public Iterator<T> iterator()
iterator in interface Iterable<T>public boolean hasMoreElements()
hasMoreElements in interface Enumeration<T>public T nextElement()
nextElement in interface Enumeration<T>public boolean isClosed()
public void close()
close in interface Closeable
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||