org.dishevelled.observable
Class AbstractObservableQueue<E>

java.lang.Object
  extended by org.dishevelled.observable.AbstractQueueDecorator<E>
      extended by org.dishevelled.observable.AbstractObservableQueue<E>
Type Parameters:
E - queue element type
All Implemented Interfaces:
Iterable<E>, Collection<E>, Queue<E>, ObservableQueue<E>
Direct Known Subclasses:
ObservableQueueImpl

public abstract class AbstractObservableQueue<E>
extends AbstractQueueDecorator<E>
implements ObservableQueue<E>

Abstract implementation of an observable queue that decorates an instance of Queue.

Version:
$Revision$ $Date$
Author:
Michael Heuer

Constructor Summary
protected AbstractObservableQueue(Queue<E> queue)
          Create a new abstract observable queue that decorates the specified queue.
 
Method Summary
 boolean add(E e)
          
 boolean addAll(Collection<? extends E> coll)
          
 void addQueueChangeListener(QueueChangeListener<E> l)
          Add the specified queue change listener.
 void addVetoableQueueChangeListener(VetoableQueueChangeListener<E> l)
          Add the specified vetoable queue change listener.
 void clear()
          
 void fireQueueChanged()
          Fire a change event to all registered QueueChangeListeners.
 void fireQueueChanged(QueueChangeEvent<E> e)
          Fire the specified change event to all registered QueueChangeListeners.
 void fireQueueWillChange()
          Fire a will change event to all registered VetoableQueueChangeListeners.
 void fireQueueWillChange(VetoableQueueChangeEvent<E> e)
          Fire the specified will change event to all registered VetoableQueueChangeListeners.
protected  ObservableQueueChangeSupport<E> getObservableQueueChangeSupport()
          Return the ObservableQueueChangeSupport class backing this abstract observable queue.
 int getQueueChangeListenerCount()
          Return the number of QueueChangeListeners registered to this observable queue.
 QueueChangeListener<E>[] getQueueChangeListeners()
          Return an array of all QueueChangeListeners, or an empty array if none are registered.
 int getVetoableQueueChangeListenerCount()
          Return the number of VetoableQueueChangeListeners registered to this observable queue.
 VetoableQueueChangeListener<E>[] getVetoableQueueChangeListeners()
          Return an array of all VetoableQueueChangeListeners, or an empty array if none are registered.
 Iterator<E> iterator()
          
 boolean offer(E e)
          
 E poll()
          
protected abstract  void postAdd(E e)
          Notify subclasses the add method has just been called on the wrapped queue with the specified parameter.
protected abstract  void postAddAll(Collection<? extends E> coll)
          Notify subclasses the addAll method has just been called on the wrapped queue with the specified parameter.
protected abstract  void postClear()
          Notify subclasses the clear method has just been called on the wrapped queue.
protected abstract  void postIteratorRemove()
          Notify subclasses the remove method has just been called on the wrapped queue's iterator.
protected abstract  void postOffer(E e)
          Notify subclasses the offer method has just been called on the wrapped queue with the specified parameter.
protected abstract  void postPoll()
          Notify subclasses the poll method has just been called on the wrapped queue.
protected abstract  void postRemove(Object o)
          Notify subclasses the remove method has just been called on the wrapped queue with the specified parameter.
protected abstract  void postRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method has just been called on the wrapped queue with the specified parameter.
protected abstract  void postRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method has just been called on the wrapped queue with the specified parameter.
protected abstract  boolean preAdd(E e)
          Notify subclasses the add method is about to be called on the wrapped queue with the specified parameter.
protected abstract  boolean preAddAll(Collection<? extends E> coll)
          Notify subclasses the addAll method is about to be called on the wrapped queue with the specified parameter.
protected abstract  boolean preClear()
          Notify subclasses the clear method is about to be called on the wrapped queue.
protected abstract  boolean preIteratorRemove()
          Notify subclasses the remove method is about to be called on the wrapped queue's iterator.
protected abstract  boolean preOffer(E e)
          Notify subclasses the offer method is about to be called on the wrapped queue with the specified parameter.
protected abstract  boolean prePoll()
          Notify subclasses the poll method is about to be called on the wrapped queue.
protected abstract  boolean preRemove(Object o)
          Notify subclasses the remove method is about to be called on the wrapped queue with the specified parameter.
protected abstract  boolean preRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method is about to be called on the wrapped queue with the specified parameter.
protected abstract  boolean preRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method is about to be called on the wrapped queue with the specified parameter.
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> coll)
          
 void removeQueueChangeListener(QueueChangeListener<E> l)
          Remove the specified queue change listener.
 void removeVetoableQueueChangeListener(VetoableQueueChangeListener<E> l)
          Remove the specified vetoable queue change listener.
 boolean retainAll(Collection<?> coll)
          
 
Methods inherited from class org.dishevelled.observable.AbstractQueueDecorator
contains, containsAll, element, equals, getQueue, hashCode, isEmpty, peek, remove, size, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Queue
element, peek, remove
 
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, size, toArray, toArray
 

Constructor Detail

AbstractObservableQueue

protected AbstractObservableQueue(Queue<E> queue)
Create a new abstract observable queue that decorates the specified queue.

Parameters:
queue - queue to decorate
Method Detail

getObservableQueueChangeSupport

protected final ObservableQueueChangeSupport<E> getObservableQueueChangeSupport()
Return the ObservableQueueChangeSupport class backing this abstract observable queue.

Returns:
the ObservableQueueChangeSupport class backing this abstract observable queue

addQueueChangeListener

public final void addQueueChangeListener(QueueChangeListener<E> l)
Add the specified queue change listener.

Specified by:
addQueueChangeListener in interface ObservableQueue<E>
Parameters:
l - queue change listener to add

removeQueueChangeListener

public final void removeQueueChangeListener(QueueChangeListener<E> l)
Remove the specified queue change listener.

Specified by:
removeQueueChangeListener in interface ObservableQueue<E>
Parameters:
l - queue change listener to remove

addVetoableQueueChangeListener

public final void addVetoableQueueChangeListener(VetoableQueueChangeListener<E> l)
Add the specified vetoable queue change listener.

Specified by:
addVetoableQueueChangeListener in interface ObservableQueue<E>
Parameters:
l - vetoable queue change listener to add

removeVetoableQueueChangeListener

public final void removeVetoableQueueChangeListener(VetoableQueueChangeListener<E> l)
Remove the specified vetoable queue change listener.

Specified by:
removeVetoableQueueChangeListener in interface ObservableQueue<E>
Parameters:
l - vetoable queue change listener to remove

getQueueChangeListeners

public final QueueChangeListener<E>[] getQueueChangeListeners()
Return an array of all QueueChangeListeners, or an empty array if none are registered.

Specified by:
getQueueChangeListeners in interface ObservableQueue<E>
Returns:
an array of all QueueChangeListeners, or an empty array if none are registered

getQueueChangeListenerCount

public final int getQueueChangeListenerCount()
Return the number of QueueChangeListeners registered to this observable queue.

Specified by:
getQueueChangeListenerCount in interface ObservableQueue<E>
Returns:
the number of QueueChangeListeners registered to this observable queue

getVetoableQueueChangeListeners

public final VetoableQueueChangeListener<E>[] getVetoableQueueChangeListeners()
Return an array of all VetoableQueueChangeListeners, or an empty array if none are registered.

Specified by:
getVetoableQueueChangeListeners in interface ObservableQueue<E>
Returns:
an array of all VetoableQueueChangeListeners, or an empty array if none are registered

getVetoableQueueChangeListenerCount

public final int getVetoableQueueChangeListenerCount()
Return the number of VetoableQueueChangeListeners registered to this observable queue.

Specified by:
getVetoableQueueChangeListenerCount in interface ObservableQueue<E>
Returns:
the number of VetoableQueueChangeListeners registered to this observable queue

fireQueueWillChange

public void fireQueueWillChange()
                         throws QueueChangeVetoException
Fire a will change event to all registered VetoableQueueChangeListeners.

Throws:
QueueChangeVetoException - if any of the listeners veto the change

fireQueueWillChange

public void fireQueueWillChange(VetoableQueueChangeEvent<E> e)
                         throws QueueChangeVetoException
Fire the specified will change event to all registered VetoableQueueChangeListeners.

Parameters:
e - will change event
Throws:
QueueChangeVetoException - if any of the listeners veto the change

fireQueueChanged

public void fireQueueChanged()
Fire a change event to all registered QueueChangeListeners.


fireQueueChanged

public void fireQueueChanged(QueueChangeEvent<E> e)
Fire the specified change event to all registered QueueChangeListeners.

Parameters:
e - change event

preAdd

protected abstract boolean preAdd(E e)
Notify subclasses the add method is about to be called on the wrapped queue with the specified parameter. Return true to proceed with the change.

Parameters:
e - add method parameter
Returns:
true to proceed with the change

postAdd

protected abstract void postAdd(E e)
Notify subclasses the add method has just been called on the wrapped queue with the specified parameter.

Parameters:
e - add method parameter

preAddAll

protected abstract boolean preAddAll(Collection<? extends E> coll)
Notify subclasses the addAll method is about to be called on the wrapped queue with the specified parameter. Return true to proceed with the change.

Parameters:
coll - addAll method parameter
Returns:
true to proceed with the change

postAddAll

protected abstract void postAddAll(Collection<? extends E> coll)
Notify subclasses the addAll method has just been called on the wrapped queue with the specified parameter.

Parameters:
coll - addAll method parameter

preClear

protected abstract boolean preClear()
Notify subclasses the clear method is about to be called on the wrapped queue. Return true to proceed with the change.

Returns:
true to proceed with the change

postClear

protected abstract void postClear()
Notify subclasses the clear method has just been called on the wrapped queue.


preRemove

protected abstract boolean preRemove(Object o)
Notify subclasses the remove method is about to be called on the wrapped queue with the specified parameter. Return true to proceed with the change.

Parameters:
o - remove method parameter
Returns:
true to proceed with the change

postRemove

protected abstract void postRemove(Object o)
Notify subclasses the remove method has just been called on the wrapped queue with the specified parameter.

Parameters:
o - remove method parameter

preRemoveAll

protected abstract boolean preRemoveAll(Collection<?> coll)
Notify subclasses the removeAll method is about to be called on the wrapped queue with the specified parameter. Return true to proceed with the change.

Parameters:
coll - removeAll method parameter
Returns:
true to proceed with the change

postRemoveAll

protected abstract void postRemoveAll(Collection<?> coll)
Notify subclasses the removeAll method has just been called on the wrapped queue with the specified parameter.

Parameters:
coll - removeAll method parameter

preRetainAll

protected abstract boolean preRetainAll(Collection<?> coll)
Notify subclasses the retainAll method is about to be called on the wrapped queue with the specified parameter. Return true to proceed with the change.

Parameters:
coll - retainAll method parameter
Returns:
true to proceed with the change

postRetainAll

protected abstract void postRetainAll(Collection<?> coll)
Notify subclasses the retainAll method has just been called on the wrapped queue with the specified parameter.

Parameters:
coll - retainAll method parameter

preIteratorRemove

protected abstract boolean preIteratorRemove()
Notify subclasses the remove method is about to be called on the wrapped queue's iterator. Return true to proceed with the change.

Returns:
true to proceed with the change

postIteratorRemove

protected abstract void postIteratorRemove()
Notify subclasses the remove method has just been called on the wrapped queue's iterator.


preOffer

protected abstract boolean preOffer(E e)
Notify subclasses the offer method is about to be called on the wrapped queue with the specified parameter. Return true to proceed with the change.

Parameters:
e - offer method parameter
Returns:
true to proceed with the change

postOffer

protected abstract void postOffer(E e)
Notify subclasses the offer method has just been called on the wrapped queue with the specified parameter.

Parameters:
e - offer method parameter

prePoll

protected abstract boolean prePoll()
Notify subclasses the poll method is about to be called on the wrapped queue. Return true to proceed with the change.

Returns:
true to proceed with the change

postPoll

protected abstract void postPoll()
Notify subclasses the poll method has just been called on the wrapped queue.


add

public boolean add(E e)

Specified by:
add in interface Collection<E>
Specified by:
add in interface Queue<E>
Overrides:
add in class AbstractQueueDecorator<E>

addAll

public boolean addAll(Collection<? extends E> coll)

Specified by:
addAll in interface Collection<E>
Overrides:
addAll in class AbstractQueueDecorator<E>

clear

public void clear()

Specified by:
clear in interface Collection<E>
Overrides:
clear in class AbstractQueueDecorator<E>

iterator

public Iterator<E> iterator()

Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>
Overrides:
iterator in class AbstractQueueDecorator<E>

remove

public boolean remove(Object o)

Specified by:
remove in interface Collection<E>
Overrides:
remove in class AbstractQueueDecorator<E>

removeAll

public boolean removeAll(Collection<?> coll)

Specified by:
removeAll in interface Collection<E>
Overrides:
removeAll in class AbstractQueueDecorator<E>

retainAll

public boolean retainAll(Collection<?> coll)

Specified by:
retainAll in interface Collection<E>
Overrides:
retainAll in class AbstractQueueDecorator<E>

offer

public boolean offer(E e)

Specified by:
offer in interface Queue<E>
Overrides:
offer in class AbstractQueueDecorator<E>

poll

public E poll()

Specified by:
poll in interface Queue<E>
Overrides:
poll in class AbstractQueueDecorator<E>


Copyright (c) 2003-2012 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).