org.dishevelled.observable
Class AbstractObservableCollection<E>

java.lang.Object
  extended by org.dishevelled.observable.AbstractCollectionDecorator<E>
      extended by org.dishevelled.observable.AbstractObservableCollection<E>
Type Parameters:
E - collection element type
All Implemented Interfaces:
Iterable<E>, Collection<E>, ObservableCollection<E>
Direct Known Subclasses:
ObservableCollectionImpl

public abstract class AbstractObservableCollection<E>
extends AbstractCollectionDecorator<E>
implements ObservableCollection<E>

Abstract implementation of an observable collection that decorates an instance of Collection.

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

Constructor Summary
protected AbstractObservableCollection(Collection<E> collection)
          Create a new abstract observable collection that decorates the specified collection.
 
Method Summary
 boolean add(E e)
          
 boolean addAll(Collection<? extends E> coll)
          
 void addCollectionChangeListener(CollectionChangeListener<E> l)
          Add the specified collection change listener.
 void addVetoableCollectionChangeListener(VetoableCollectionChangeListener<E> l)
          Add the specified vetoable collection change listener.
 void clear()
          
 void fireCollectionChanged()
          Fire a change event to all registered CollectionChangeListeners.
 void fireCollectionChanged(CollectionChangeEvent<E> e)
          Fire the specified change event to all registered CollectionChangeListeners.
 void fireCollectionWillChange()
          Fire a will change event to all registered VetoableCollectionChangeListeners.
 void fireCollectionWillChange(VetoableCollectionChangeEvent<E> e)
          Fire the specified will change event to all registered VetoableCollectionChangeListeners.
 int getCollectionChangeListenerCount()
          Return the number of CollectionChangeListeners registered to this observable collection.
 CollectionChangeListener<E>[] getCollectionChangeListeners()
          Return an array of all CollectionChangeListeners, or an empty array if none are registered.
protected  ObservableCollectionChangeSupport<E> getObservableCollectionChangeSupport()
          Return the ObservableCollectionChangeSupport class backing this abstract observable collection.
 int getVetoableCollectionChangeListenerCount()
          Return the number of VetoableCollectionChangeListeners registered to this observable collection.
 VetoableCollectionChangeListener<E>[] getVetoableCollectionChangeListeners()
          Return an array of all VetoableCollectionChangeListeners, or an empty array if none are registered.
 Iterator<E> iterator()
          
protected abstract  void postAdd(E e)
          Notify subclasses the add method has just been called on the wrapped collection with the specified parameter.
protected abstract  void postAddAll(Collection<? extends E> coll)
          Notify subclasses the addAll method has just been called on the wrapped collection with the specified parameter.
protected abstract  void postClear()
          Notify subclasses the clear method has just been called on the wrapped collection.
protected abstract  void postIteratorRemove()
          Notify subclasses the remove method has just been called on the wrapped collection's iterator.
protected abstract  void postRemove(Object o)
          Notify subclasses the remove method has just been called on the wrapped collection with the specified parameter.
protected abstract  void postRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method has just been called on the wrapped collection with the specified parameter.
protected abstract  void postRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method has just been called on the wrapped collection with the specified parameter.
protected abstract  boolean preAdd(E e)
          Notify subclasses the add method is about to be called on the wrapped collection 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 collection with the specified parameter.
protected abstract  boolean preClear()
          Notify subclasses the clear method is about to be called on the wrapped collection.
protected abstract  boolean preIteratorRemove()
          Notify subclasses the remove method is about to be called on the wrapped collection's iterator.
protected abstract  boolean preRemove(Object o)
          Notify subclasses the remove method is about to be called on the wrapped collection with the specified parameter.
protected abstract  boolean preRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method is about to be called on the wrapped collection with the specified parameter.
protected abstract  boolean preRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method is about to be called on the wrapped collection with the specified parameter.
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> coll)
          
 void removeCollectionChangeListener(CollectionChangeListener<E> l)
          Remove the specified collection change listener.
 void removeVetoableCollectionChangeListener(VetoableCollectionChangeListener<E> l)
          Remove the specified vetoable collection change listener.
 boolean retainAll(Collection<?> coll)
          
 
Methods inherited from class org.dishevelled.observable.AbstractCollectionDecorator
contains, containsAll, equals, getCollection, hashCode, isEmpty, 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.Collection
contains, containsAll, equals, hashCode, isEmpty, size, toArray, toArray
 

Constructor Detail

AbstractObservableCollection

protected AbstractObservableCollection(Collection<E> collection)
Create a new abstract observable collection that decorates the specified collection.

Parameters:
collection - collection to decorate
Method Detail

getObservableCollectionChangeSupport

protected final ObservableCollectionChangeSupport<E> getObservableCollectionChangeSupport()
Return the ObservableCollectionChangeSupport class backing this abstract observable collection.

Returns:
the ObservableCollectionChangeSupport class backing this abstract observable collection

addCollectionChangeListener

public final void addCollectionChangeListener(CollectionChangeListener<E> l)
Add the specified collection change listener.

Specified by:
addCollectionChangeListener in interface ObservableCollection<E>
Parameters:
l - collection change listener to add

removeCollectionChangeListener

public final void removeCollectionChangeListener(CollectionChangeListener<E> l)
Remove the specified collection change listener.

Specified by:
removeCollectionChangeListener in interface ObservableCollection<E>
Parameters:
l - collection change listener to remove

addVetoableCollectionChangeListener

public final void addVetoableCollectionChangeListener(VetoableCollectionChangeListener<E> l)
Add the specified vetoable collection change listener.

Specified by:
addVetoableCollectionChangeListener in interface ObservableCollection<E>
Parameters:
l - vetoable collection change listener to add

removeVetoableCollectionChangeListener

public final void removeVetoableCollectionChangeListener(VetoableCollectionChangeListener<E> l)
Remove the specified vetoable collection change listener.

Specified by:
removeVetoableCollectionChangeListener in interface ObservableCollection<E>
Parameters:
l - vetoable collection change listener to remove

getCollectionChangeListeners

public final CollectionChangeListener<E>[] getCollectionChangeListeners()
Return an array of all CollectionChangeListeners, or an empty array if none are registered.

Specified by:
getCollectionChangeListeners in interface ObservableCollection<E>
Returns:
an array of all CollectionChangeListeners, or an empty array if none are registered

getCollectionChangeListenerCount

public final int getCollectionChangeListenerCount()
Return the number of CollectionChangeListeners registered to this observable collection.

Specified by:
getCollectionChangeListenerCount in interface ObservableCollection<E>
Returns:
the number of CollectionChangeListeners registered to this observable collection

getVetoableCollectionChangeListeners

public final VetoableCollectionChangeListener<E>[] getVetoableCollectionChangeListeners()
Return an array of all VetoableCollectionChangeListeners, or an empty array if none are registered.

Specified by:
getVetoableCollectionChangeListeners in interface ObservableCollection<E>
Returns:
an array of all VetoableCollectionChangeListeners, or an empty array if none are registered

getVetoableCollectionChangeListenerCount

public final int getVetoableCollectionChangeListenerCount()
Return the number of VetoableCollectionChangeListeners registered to this observable collection.

Specified by:
getVetoableCollectionChangeListenerCount in interface ObservableCollection<E>
Returns:
the number of VetoableCollectionChangeListeners registered to this observable collection

fireCollectionWillChange

public void fireCollectionWillChange()
                              throws CollectionChangeVetoException
Fire a will change event to all registered VetoableCollectionChangeListeners.

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

fireCollectionWillChange

public void fireCollectionWillChange(VetoableCollectionChangeEvent<E> e)
                              throws CollectionChangeVetoException
Fire the specified will change event to all registered VetoableCollectionChangeListeners.

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

fireCollectionChanged

public void fireCollectionChanged()
Fire a change event to all registered CollectionChangeListeners.


fireCollectionChanged

public void fireCollectionChanged(CollectionChangeEvent<E> e)
Fire the specified change event to all registered CollectionChangeListeners.

Parameters:
e - change event

preAdd

protected abstract boolean preAdd(E e)
Notify subclasses the add method is about to be called on the wrapped collection 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 collection 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 collection 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 collection 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 collection. 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 collection.


preRemove

protected abstract boolean preRemove(Object o)
Notify subclasses the remove method is about to be called on the wrapped collection 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 collection 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 collection 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 collection 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 collection 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 collection 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 collection'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 collection's iterator.


add

public boolean add(E e)

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

addAll

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

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

clear

public void clear()

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

iterator

public Iterator<E> iterator()

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

remove

public boolean remove(Object o)

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

removeAll

public boolean removeAll(Collection<?> coll)

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

retainAll

public boolean retainAll(Collection<?> coll)

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


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