org.isam.exehda.services.ctxm
Class ContextEventQueue

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--org.isam.exehda.services.ctxm.ContextEventQueue
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

class ContextEventQueue
extends java.util.Vector

Implements a 'smart' queue (First-In First-Out) for storing context events. By smart we mean the policy of insertion of new events in the queue may be tunned according to the context semantics demand. For example, curretly events would either be appended or cause the oler events to be droped. In future, more advanced policies should also be implemented.

Version:
$Date: 2004/12/30 23:06:15 $ $Revision: 1.2 $
Author:
last modified by $Author: lucc $

Nested Class Summary
static interface ContextEventQueue.QueuingPolicy
           
 
Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ContextEventQueue()
          Creates a new ContextEventQueue instance with default APPEND policy.
ContextEventQueue(int policy)
          Creates a new ContextEventQueue instance with the given event insertion policy.
 
Method Summary
 boolean isEmpty()
          Returns whether this queue is empty (size()==0) or not.
 ContextEvent pop()
          Consumes the event in the queue's head, returning that element.
 void push(ContextEvent ev)
          Appends a new event to the tail of the queue.
 int size()
          Returns the number os events still in the queue.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

ContextEventQueue

public ContextEventQueue()
Creates a new ContextEventQueue instance with default APPEND policy.


ContextEventQueue

public ContextEventQueue(int policy)
Creates a new ContextEventQueue instance with the given event insertion policy.

Parameters:
policy - an int value
Method Detail

push

public void push(ContextEvent ev)
Appends a new event to the tail of the queue. Depending on the configured queuing policy, older events may be dropped.

Parameters:
ev - a ContextEvent value

pop

public ContextEvent pop()
Consumes the event in the queue's head, returning that element.

Returns:
the event that was in the head of the queue

isEmpty

public boolean isEmpty()
Returns whether this queue is empty (size()==0) or not.

Specified by:
isEmpty in interface java.util.List
Overrides:
isEmpty in class java.util.Vector
Returns:
true if the queue is empty, false otherwise.

size

public int size()
Returns the number os events still in the queue.

Specified by:
size in interface java.util.List
Overrides:
size in class java.util.Vector
Returns:
a int value >= 0