org.activemq.service.impl
Class QueueListSupport

java.lang.Object
  extended by org.activemq.service.impl.QueueListSupport
All Implemented Interfaces:
QueueList

public abstract class QueueListSupport
extends Object
implements QueueList

A base class which is useful for implementation inheritence when implementing a persistent QueueList

Version:
$Revision: 1.1.1.1 $

Nested Class Summary
static class QueueListSupport.Header
           
static class QueueListSupport.Node
           
 
Field Summary
protected static Long HEAD_KEY
           
 
Fields inherited from interface org.activemq.service.QueueList
EMPTY_ARRAY
 
Constructor Summary
QueueListSupport()
           
 
Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list.
 QueueListEntry add(Object value)
          Appends the specified element to the end of this list.
 QueueListEntry addBefore(Object value, QueueListEntry entry)
          Insert an Entry before this entry
 QueueListEntry addFirst(Object value)
          Inserts the given element at the beginning of this list.
 QueueListEntry addLast(Object value)
          Appends the given element to the end of this list.
 boolean contains(Object value)
          Returns true if this list contains the specified element.
protected  Long createKey(QueueListSupport.Header header)
           
protected  QueueListSupport.Node createNode()
           
protected  QueueListSupport.Node doAddBefore(QueueListSupport.Header header, QueueListSupport.Node nextNode, Object element)
           
protected  QueueListSupport.Node doAddLast(Object value, QueueListSupport.Header header)
           
protected abstract  void doRemoveNode(QueueListSupport.Node node)
           
 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
protected abstract  QueueListSupport.Header getHeader()
          Looks up the header object, lazily creating one if the current table is empty
 Object getLast()
          Returns the last element in this list.
 QueueListEntry getLastEntry()
          Retrieve the last entry for the linked list
 QueueListEntry getNextEntry(QueueListEntry entry)
          Retrieve the next entry after this entry
protected  QueueListSupport.Node getNode(int index)
           
protected abstract  QueueListSupport.Node getNode(Long key)
           
protected  QueueListSupport.Node getNode(QueueListSupport.Header header, int index)
           
 QueueListEntry getPrevEntry(QueueListEntry entry)
          Retrive the previous entry after this entry
 int indexOf(Object value)
          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 value)
          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.
 void remove(QueueListEntry entry)
          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.
protected  boolean removeNode(QueueListSupport.Node node)
           
 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.
protected static long unwrapLong(Long key)
           
protected abstract  void updateHeader(QueueListSupport.Header header)
          Writes the header back to disk after its been changed
protected  void updateNextNode(Long nextKey, Long key)
           
protected abstract  void updateNode(QueueListSupport.Node node)
          Updates the node
protected  void updatePreviousNode(Long previousKey, Long key)
           
protected static Long wrapLong(long value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.activemq.service.QueueList
clear, remove
 

Field Detail

HEAD_KEY

protected static final Long HEAD_KEY
Constructor Detail

QueueListSupport

public QueueListSupport()
Method Detail

getFirst

public Object getFirst()
                throws JMSException
Description copied from interface: QueueList
Returns the first element in this list.

Specified by:
getFirst in interface QueueList
Returns:
the first element in this list.
Throws:
JMSException

getLast

public Object getLast()
               throws JMSException
Description copied from interface: QueueList
Returns the last element in this list.

Specified by:
getLast in interface QueueList
Returns:
the last element in this list.
Throws:
JMSException

removeFirst

public Object removeFirst()
                   throws JMSException
Description copied from interface: QueueList
Removes and returns the first element from this list.

Specified by:
removeFirst in interface QueueList
Returns:
the first element from this list.
Throws:
JMSException

removeLast

public Object removeLast()
                  throws JMSException
Description copied from interface: QueueList
Removes and returns the last element from this list.

Specified by:
removeLast in interface QueueList
Returns:
the last element from this list.
Throws:
JMSException

addFirst

public QueueListEntry addFirst(Object value)
                        throws JMSException
Description copied from interface: QueueList
Inserts the given element at the beginning of this list.

Specified by:
addFirst in interface QueueList
Parameters:
value - the element to be inserted at the beginning of this list.
Returns:
the DefaultQueueListEntry
Throws:
JMSException

addLast

public QueueListEntry addLast(Object value)
                       throws JMSException
Description copied from interface: QueueList
Appends the given element to the end of this list. (Identical in function to the add method; included only for consistency.)

Specified by:
addLast in interface QueueList
Parameters:
value - the element to be inserted at the end of this list.
Returns:
the DefaultQueueListEntry
Throws:
JMSException

contains

public boolean contains(Object value)
                 throws JMSException
Description copied from interface: QueueList
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)).

Specified by:
contains in interface QueueList
Parameters:
value - 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
Description copied from interface: QueueList
Returns the number of elements in this list.

Specified by:
size in interface QueueList
Returns:
the number of elements in this list.
Throws:
JMSException

isEmpty

public boolean isEmpty()
                throws JMSException
Description copied from interface: QueueList
is the list empty?

Specified by:
isEmpty in interface QueueList
Returns:
true if there are no elements in the list
Throws:
JMSException

add

public QueueListEntry add(Object value)
                   throws JMSException
Description copied from interface: QueueList
Appends the specified element to the end of this list.

Specified by:
add in interface QueueList
Parameters:
value - element to be appended to this list.
Returns:
the DefaultQueueListEntry
Throws:
JMSException

get

public Object get(int index)
           throws JMSException
Description copied from interface: QueueList
Returns the element at the specified position in this list.

Specified by:
get in interface QueueList
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.
Throws:
JMSException

set

public Object set(int index,
                  Object element)
           throws JMSException
Description copied from interface: QueueList
Replaces the element at the specified position in this list with the specified element.

Specified by:
set in interface QueueList
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:
JMSException

add

public void add(int index,
                Object element)
         throws JMSException
Description copied from interface: QueueList
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).

Specified by:
add in interface QueueList
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
JMSException

remove

public Object remove(int index)
              throws JMSException
Description copied from interface: QueueList
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.

Specified by:
remove in interface QueueList
Parameters:
index - the index of the element to removed.
Returns:
the element previously at the specified position.
Throws:
JMSException

indexOf

public int indexOf(Object value)
            throws JMSException
Description copied from interface: QueueList
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.

Specified by:
indexOf in interface QueueList
Parameters:
value - 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 value)
                throws JMSException
Description copied from interface: QueueList
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.

Specified by:
lastIndexOf in interface QueueList
Parameters:
value - 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
Description copied from interface: QueueList
Retrieve the first entry for the linked list

Specified by:
getFirstEntry in interface QueueList
Returns:
first entry or null
Throws:
JMSException

getLastEntry

public QueueListEntry getLastEntry()
                            throws JMSException
Description copied from interface: QueueList
Retrieve the last entry for the linked list

Specified by:
getLastEntry in interface QueueList
Returns:
last entry or null
Throws:
JMSException

getNextEntry

public QueueListEntry getNextEntry(QueueListEntry entry)
                            throws JMSException
Description copied from interface: QueueList
Retrieve the next entry after this entry

Specified by:
getNextEntry in interface QueueList
Returns:
Throws:
JMSException

getPrevEntry

public QueueListEntry getPrevEntry(QueueListEntry entry)
                            throws JMSException
Description copied from interface: QueueList
Retrive the previous entry after this entry

Specified by:
getPrevEntry in interface QueueList
Returns:
Throws:
JMSException

addBefore

public QueueListEntry addBefore(Object value,
                                QueueListEntry entry)
                         throws JMSException
Description copied from interface: QueueList
Insert an Entry before this entry

Specified by:
addBefore in interface QueueList
Parameters:
value - the elment to insert
entry - the Entry to insert the object before
Returns:
Throws:
JMSException

remove

public void remove(QueueListEntry entry)
            throws JMSException
Description copied from interface: QueueList
Remove a DefaultQueueListEntry

Specified by:
remove in interface QueueList
Parameters:
entry - the DefaultQueueListEntry
Throws:
JMSException

toArray

public Object[] toArray()
                 throws JMSException
Description copied from interface: QueueList
Returns an array containing all of the elements in this list in the correct order.

Specified by:
toArray in interface QueueList
Returns:
an array containing all of the elements in this list in the correct order.
Throws:
JMSException

rotate

public void rotate()
            throws JMSException
Description copied from interface: QueueList
Move the head of the list to the back of the list

Specified by:
rotate in interface QueueList
Throws:
JMSException

createKey

protected Long createKey(QueueListSupport.Header header)
                  throws IOException,
                         JMSException
Throws:
IOException
JMSException

removeNode

protected boolean removeNode(QueueListSupport.Node node)
                      throws IOException,
                             JMSException
Throws:
IOException
JMSException

getHeader

protected abstract QueueListSupport.Header getHeader()
                                              throws IOException,
                                                     JMSException
Looks up the header object, lazily creating one if the current table is empty

Returns:
Throws:
IOException
JMSException

updateHeader

protected abstract void updateHeader(QueueListSupport.Header header)
                              throws IOException,
                                     JMSException
Writes the header back to disk after its been changed

Parameters:
header -
Throws:
IOException
JMSException

updateNode

protected abstract void updateNode(QueueListSupport.Node node)
                            throws IOException,
                                   JMSException
Updates the node

Parameters:
node -
Throws:
IOException
JMSException

getNode

protected abstract QueueListSupport.Node getNode(Long key)
                                          throws IOException,
                                                 JMSException
Throws:
IOException
JMSException

getNode

protected QueueListSupport.Node getNode(int index)
                                 throws IOException,
                                        JMSException
Throws:
IOException
JMSException

getNode

protected QueueListSupport.Node getNode(QueueListSupport.Header header,
                                        int index)
                                 throws IOException,
                                        JMSException
Throws:
IOException
JMSException

doAddLast

protected QueueListSupport.Node doAddLast(Object value,
                                          QueueListSupport.Header header)
                                   throws IOException,
                                          JMSException
Throws:
IOException
JMSException

updateNextNode

protected void updateNextNode(Long nextKey,
                              Long key)
                       throws IOException,
                              JMSException
Throws:
IOException
JMSException

updatePreviousNode

protected void updatePreviousNode(Long previousKey,
                                  Long key)
                           throws IOException,
                                  JMSException
Throws:
IOException
JMSException

doAddBefore

protected QueueListSupport.Node doAddBefore(QueueListSupport.Header header,
                                            QueueListSupport.Node nextNode,
                                            Object element)
                                     throws JMSException,
                                            IOException
Throws:
JMSException
IOException

doRemoveNode

protected abstract void doRemoveNode(QueueListSupport.Node node)
                              throws IOException,
                                     JMSException
Throws:
IOException
JMSException

wrapLong

protected static Long wrapLong(long value)

unwrapLong

protected static long unwrapLong(Long key)

createNode

protected QueueListSupport.Node createNode()


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