uk.org.ogsadai.common
Interface Queue

All Known Implementing Classes:
FIFOQueue

public interface Queue

A subset of methods from the java.util.Queue interface introduced in Java 5.0.

Includes suffient methods from Queue to enable the implementation of simple FIFO queues for use within OGSA-DAI.

Excludes all methods in the java.util.Iterable and java.util.Collection interfaces except iterator() and size().

As in Java 5.0, Queue implementations do not allow the insertion of null elements.

Author:
The OGSA-DAI Project team

Method Summary
 java.lang.Object element()
          Retrieves the head of the queue without removing it.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this queue.
 boolean offer(java.lang.Object item)
          Inserts, if possible, an object into the queue.
 java.lang.Object peek()
          Retrieves the head of the queue without removing it.
 java.lang.Object poll()
          Retrieves and removes the head of the queue.
 java.lang.Object remove()
          Retrieves and removes the head of the queue.
 void remove(java.lang.Object item)
          Removes the specified item from the queue.
 int size()
          Returns the number of elements in this queue.
 

Method Detail

offer

public boolean offer(java.lang.Object item)
Inserts, if possible, an object into the queue.

Parameters:
item - The item to insert. Must not be null.
Returns:
true if it was possible to add the element to this queue, otherwise false.

poll

public java.lang.Object poll()
Retrieves and removes the head of the queue.

Returns:
the head of the queue, or null if the queue is empty.

remove

public java.lang.Object remove()
                        throws java.util.NoSuchElementException
Retrieves and removes the head of the queue. Unlike poll, which performs a similar task, this method throws an exception if called on an empty queue.

Returns:
the head of the queue.
Throws:
java.util.NoSuchElementException - if this queue is empty.

remove

public void remove(java.lang.Object item)
            throws java.util.NoSuchElementException
Removes the specified item from the queue.

Parameters:
item - The item to remove.
Throws:
java.util.NoSuchElementException - if this queue is empty.

peek

public java.lang.Object peek()
Retrieves the head of the queue without removing it.

Returns:
the head of this queue, or null if the queue is empty.

element

public java.lang.Object element()
                         throws java.util.NoSuchElementException
Retrieves the head of the queue without removing it. Unlike peek, which performs a similar task, this method throws an exception if called on an empty queue.

Returns:
the head of this queue.
Throws:
java.util.NoSuchElementException - if this queue is empty.

size

public int size()
Returns the number of elements in this queue.

Returns:
the number of elements in the queue.

iterator

public java.util.Iterator iterator()
                            throws java.util.ConcurrentModificationException
Returns an iterator over the elements in this queue. The order of iteration is the same as the order of the elements in the queue at the time this method is called.

Returns:
an iterator over the elements in the queue.
Throws:
java.util.ConcurrentModificationException - if the order of the queue is changed while the iterator is in use.