fipaos.util
Class Queue

Direct Known Subclasses:
FIFOQueue, LIFOQueue

public abstract class Queue

This is a simple class which defines methods which all queues
should implement




Method Summary
 synchronized voidaddItem(Object obj)
          Adds an object to the queue
 synchronized voidflush()
          Method to flush the contents of the queue
 synchronized ObjectgetItem()
          Get the next message from the queue.
 synchronized ObjectgetItemWithoutBlocking()
          Get the next message from the queue.
 synchronized booleanisEmpty()
          Method to determine if the queue is empty
 synchronized booleanisFull()
          Method to determine if the queue is full
 static voidmain(String[] args)
          Test harness for the various Queue implementations
 intqueueLength()
          Returns the number of items currently in the queue.
 synchronized voidreleaseBlock()
          Method to release all blocked threads within the queue - once
invoked, getItem() will never block again

Method Detail

addItem

public synchronized void addItem(Object obj)
Adds an object to the queue
Parameters:
obj - The object to add, given that the queue is not full

flush

public synchronized void flush()
Method to flush the contents of the queue

getItem

public synchronized Object getItem()
Get the next message from the queue. If
the queue is empty, the thread will block
until a message is added.
Returns: The next message in the queue, or null
if the thread is interrupted

getItemWithoutBlocking

public synchronized Object getItemWithoutBlocking()
Get the next message from the queue. If
the queue is empty, return null immediately.
Returns: The next message in the queue or null

isEmpty

public synchronized boolean isEmpty()
Method to determine if the queue is empty
Returns: True if the queue is empty

isFull

public synchronized boolean isFull()
Method to determine if the queue is full
Returns: True if the queue is at full capacity

main

public static void main(String[] args)
throws java.lang.Throwable
Test harness for the various Queue implementations

queueLength

public int queueLength()
Returns the number of items currently in the queue.

releaseBlock

public synchronized void releaseBlock()
Method to release all blocked threads within the queue - once
invoked, getItem() will never block again

Association Links

to Class java.util.Vector

Vector containing the message queue