org.activemq.service
Interface QueueList

All Known Implementing Classes:
DefaultQueueList, QueueListSupport

public interface QueueList

Represents a Queue with List like semantics, allowing addition and removal at any point in the queue. Typically this will be implemented using some kind of LinkedList

Version:
$Revision: 1.1.1.1 $

Field Summary
static Object[] EMPTY_ARRAY
           
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list.
 QueueListEntry add(Object o)
          Appends the specified element to the end of this list.
 QueueListEntry addBefore(Object o, QueueListEntry node)
          Insert an Entry before this entry
 QueueListEntry addFirst(Object o)
          Inserts the given element at the beginning of this list.
 QueueListEntry addLast(Object o)
          Appends the given element to the end of this list.
 void clear()
          Removes all of the elements from this list.
 boolean contains(Object o)
          Returns true if this list contains the specified element.
 Object get(int index)
          Returns the element at the specified position in this list.
 Object getFirst()
          Returns the first element in this list.
 QueueListEntry getFirstEntry()
          Retrieve the first entry for the linked list
 Object getLast()
          Returns the last element in this list.
 QueueListEntry getLastEntry()
          Retrieve the last entry for the linked list
 QueueListEntry getNextEntry(QueueListEntry node)
          Retrieve the next entry after this entry
 QueueListEntry getPrevEntry(QueueListEntry node)
          Retrive the previous entry after this entry
 int indexOf(Object o)
          Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element.
 boolean isEmpty()
          is the list empty?
 int lastIndexOf(Object o)
          Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.
 Object remove(int index)
          Removes the element at the specified position in this list.
 boolean remove(Object o)
          Removes the first occurrence of the specified element in this list.
 void remove(QueueListEntry node)
          Remove a DefaultQueueListEntry
 Object removeFirst()
          Removes and returns the first element from this list.
 Object removeLast()
          Removes and returns the last element from this list.
 void rotate()
          Move the head of the list to the back of the list
 Object set(int index, Object element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the number of elements in this list.
 Object[] toArray()
          Returns an array containing all of the elements in this list in the correct order.
 

Field Detail

EMPTY_ARRAY

public static final Object[] EMPTY_ARRAY
Method Detail

getFirst

public Object getFirst()
                throws JMSException
Returns the first element in this list.

Returns:
the first element in this list.
Throws:
JMSException

getLast

public Object getLast()
               throws JMSException
Returns the last element in this list.

Returns:
the last element in this list.
Throws:
JMSException

removeFirst

public Object removeFirst()
                   throws JMSException
Removes and returns the first element from this list.

Returns:
the first element from this list.
Throws:
JMSException

rotate

public void rotate()
            throws JMSException
Move the head of the list to the back of the list

Throws:
JMSException

removeLast

public Object removeLast()
                  throws JMSException
Removes and returns the last element from this list.

Returns:
the last element from this list.
Throws:
JMSException

addFirst

public QueueListEntry addFirst(Object o)
                        throws JMSException
Inserts the given element at the beginning of this list.

Parameters:
o - the element to be inserted at the beginning of this list.
Returns:
the DefaultQueueListEntry
Throws:
JMSException

addLast

public QueueListEntry addLast(Object o)
                       throws JMSException
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

Parameters:
o - the element to be inserted at the end of this list.
Returns:
the DefaultQueueListEntry
Throws:
JMSException

contains

public boolean contains(Object o)
                 throws JMSException
Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).

Parameters:
o - element whose presence in this list is to be tested.
Returns:
true if this list contains the specified element.
Throws:
JMSException

size

public int size()
         throws JMSException
Returns the number of elements in this list.

Returns:
the number of elements in this list.
Throws:
JMSException

isEmpty

public boolean isEmpty()
                throws JMSException
is the list empty?

Returns:
true if there are no elements in the list
Throws:
JMSException

add

public QueueListEntry add(Object o)
                   throws JMSException
Appends the specified element to the end of this list.

Parameters:
o - element to be appended to this list.
Returns:
the DefaultQueueListEntry
Throws:
JMSException

remove

public boolean remove(Object o)
               throws JMSException
Removes the first occurrence of the specified element in this list. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists).

Parameters:
o - element to be removed from this list, if present.
Returns:
true if the list contained the specified element.
Throws:
JMSException

clear

public void clear()
           throws JMSException
Removes all of the elements from this list.

Throws:
JMSException

get

public Object get(int index)
           throws JMSException
Returns the element at the specified position in this list.

Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range (index < 0 || index >= size()).
JMSException

set

public Object set(int index,
                  Object element)
           throws JMSException
Replaces the element at the specified position in this list with the specified element.

Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns:
the element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).
JMSException

add

public void add(int index,
                Object element)
         throws JMSException
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).
JMSException

remove

public Object remove(int index)
              throws JMSException
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters:
index - the index of the element to removed.
Returns:
the element previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).
JMSException

indexOf

public int indexOf(Object o)
            throws JMSException
Returns the index in this list of the first occurrence of the specified element, or -1 if the List does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Parameters:
o - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if the list does not contain this element.
Throws:
JMSException

lastIndexOf

public int lastIndexOf(Object o)
                throws JMSException
Returns the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.

Parameters:
o - element to search for.
Returns:
the index in this list of the last occurrence of the specified element, or -1 if the list does not contain this element.
Throws:
JMSException

getFirstEntry

public QueueListEntry getFirstEntry()
                             throws JMSException
Retrieve the first entry for the linked list

Returns:
first entry or null
Throws:
JMSException

getLastEntry

public QueueListEntry getLastEntry()
                            throws JMSException
Retrieve the last entry for the linked list

Returns:
last entry or null
Throws:
JMSException

getNextEntry

public QueueListEntry getNextEntry(QueueListEntry node)
                            throws JMSException
Retrieve the next entry after this entry

Parameters:
node -
Returns:
Throws:
JMSException

getPrevEntry

public QueueListEntry getPrevEntry(QueueListEntry node)
                            throws JMSException
Retrive the previous entry after this entry

Parameters:
node -
Returns:
Throws:
JMSException

addBefore

public QueueListEntry addBefore(Object o,
                                QueueListEntry node)
                         throws JMSException
Insert an Entry before this entry

Parameters:
o - the elment to insert
node - the Entry to insert the object before
Returns:
Throws:
JMSException

remove

public void remove(QueueListEntry node)
            throws JMSException
Remove a DefaultQueueListEntry

Parameters:
node - the DefaultQueueListEntry
Throws:
JMSException

toArray

public Object[] toArray()
                 throws JMSException
Returns an array containing all of the elements in this list in the correct order.

Returns:
an array containing all of the elements in this list in the correct order.
Throws:
JMSException


Copyright © 2004-2007 Protique, Ltd.. All Rights Reserved.