T - The type of elements in the queue.public class FileObjectQueue<T> extends Object implements ObjectQueue<T>
The add( Object ), peek(), remove(), and
setListener(ObjectQueue.Listener) methods may throw a
FileException if the underlying QueueFile experiences an
IOException.
| Modifier and Type | Class and Description |
|---|---|
static interface |
FileObjectQueue.Converter<T>
Convert a byte stream to and from a concrete type.
|
ObjectQueue.Listener<T>| Constructor and Description |
|---|
FileObjectQueue(File file,
FileObjectQueue.Converter<T> converter) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(T entry)
Enqueues an entry that can be processed at any time.
|
List<T> |
asList() |
void |
close() |
T |
peek()
Returns the head of the queue, or
null if the queue is empty. |
List<T> |
peek(int max)
Reads up to
max entries from the head of the queue without removing the entries. |
void |
remove()
Removes the head of the queue.
|
void |
remove(int n) |
void |
setListener(ObjectQueue.Listener<T> listener)
Sets a listener on this queue.
|
int |
size()
Returns the number of entries in the queue.
|
public FileObjectQueue(File file, FileObjectQueue.Converter<T> converter) throws IOException
IOExceptionpublic int size()
ObjectQueuesize in interface ObjectQueue<T>public final void add(T entry)
ObjectQueueadd in interface ObjectQueue<T>public T peek()
ObjectQueuenull if the queue is empty. Does not modify the
queue.peek in interface ObjectQueue<T>public final void remove()
ObjectQueueremove in interface ObjectQueue<T>public final void remove(int n)
throws IOException
IOExceptionpublic final void close()
public void setListener(ObjectQueue.Listener<T> listener)
ObjectQueueObjectQueue.Listener.onAdd(com.squareup.tape.ObjectQueue<T>, T) once for each entry that's
already in the queue. If an error occurs while reading the data, the listener will not receive
further notifications.setListener in interface ObjectQueue<T>Copyright © 2015 Square, Inc.. All Rights Reserved.