org.dishevelled.observable
Class AbstractObservableSet<E>

java.lang.Object
  extended by org.dishevelled.observable.AbstractSetDecorator<E>
      extended by org.dishevelled.observable.AbstractObservableSet<E>
Type Parameters:
E - set element type
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, ObservableSet<E>
Direct Known Subclasses:
ObservableSetImpl

public abstract class AbstractObservableSet<E>
extends AbstractSetDecorator<E>
implements ObservableSet<E>

Abstract implementation of an observable set that decorates an instance of Set.

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

Constructor Summary
protected AbstractObservableSet(Set<E> set)
          Create a new abstract observable set that decorates the specified set.
 
Method Summary
 boolean add(E e)
          
 boolean addAll(Collection<? extends E> coll)
          
 void addSetChangeListener(SetChangeListener<E> l)
          Add the specified set change listener.
 void addVetoableSetChangeListener(VetoableSetChangeListener<E> l)
          Add the specified vetoable set change listener.
 void clear()
          
 void fireSetChanged()
          Fire a change event to all registered SetChangeListeners.
 void fireSetChanged(SetChangeEvent<E> e)
          Fire the specified change event to all registered SetChangeListeners.
 void fireSetWillChange()
          Fire a will change event to all registered VetoableSetChangeListeners.
 void fireSetWillChange(VetoableSetChangeEvent<E> e)
          Fire the specified will change event to all registered VetoableSetChangeListeners.
protected  ObservableSetChangeSupport<E> getObservableSetChangeSupport()
          Return the ObservableSetChangeSupport class backing this abstract observable set.
 int getSetChangeListenerCount()
          Return the number of SetChangeListeners registered to this observable set.
 SetChangeListener<E>[] getSetChangeListeners()
          Return an array of all SetChangeListeners, or an empty array if none are registered.
 int getVetoableSetChangeListenerCount()
          Return the number of VetoableSetChangeListeners registered to this observable set.
 VetoableSetChangeListener<E>[] getVetoableSetChangeListeners()
          Return an array of all VetoableSetChangeListeners, 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 set with the specified parameter.
protected abstract  void postAddAll(Collection<? extends E> coll)
          Notify subclasses the addAll method has just been called on the wrapped set with the specified parameter.
protected abstract  void postClear()
          Notify subclasses the clear method has just been called on the wrapped set.
protected abstract  void postIteratorRemove()
          Notify subclasses the remove method has just been called on the wrapped set's iterator.
protected abstract  void postRemove(Object o)
          Notify subclasses the remove method has just been called on the wrapped set with the specified parameter.
protected abstract  void postRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method has just been called on the wrapped set with the specified parameter.
protected abstract  void postRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method has just been called on the wrapped set with the specified parameter.
protected abstract  boolean preAdd(E e)
          Notify subclasses the add method is about to be called on the wrapped set 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 set with the specified parameter.
protected abstract  boolean preClear()
          Notify subclasses the clear method is about to be called on the wrapped set.
protected abstract  boolean preIteratorRemove()
          Notify subclasses the remove method is about to be called on the wrapped set's iterator.
protected abstract  boolean preRemove(Object o)
          Notify subclasses the remove method is about to be called on the wrapped set with the specified parameter.
protected abstract  boolean preRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method is about to be called on the wrapped set with the specified parameter.
protected abstract  boolean preRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method is about to be called on the wrapped set with the specified parameter.
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> coll)
          
 void removeSetChangeListener(SetChangeListener<E> l)
          Remove the specified set change listener.
 void removeVetoableSetChangeListener(VetoableSetChangeListener<E> l)
          Remove the specified vetoable set change listener.
 boolean retainAll(Collection<?> coll)
          
 
Methods inherited from class org.dishevelled.observable.AbstractSetDecorator
contains, containsAll, equals, getSet, 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.Set
contains, containsAll, equals, hashCode, isEmpty, size, toArray, toArray
 

Constructor Detail

AbstractObservableSet

protected AbstractObservableSet(Set<E> set)
Create a new abstract observable set that decorates the specified set.

Parameters:
set - set to decorate
Method Detail

getObservableSetChangeSupport

protected final ObservableSetChangeSupport<E> getObservableSetChangeSupport()
Return the ObservableSetChangeSupport class backing this abstract observable set.

Returns:
the ObservableSetChangeSupport class backing this abstract observable set

addSetChangeListener

public final void addSetChangeListener(SetChangeListener<E> l)
Add the specified set change listener.

Specified by:
addSetChangeListener in interface ObservableSet<E>
Parameters:
l - set change listener to add

removeSetChangeListener

public final void removeSetChangeListener(SetChangeListener<E> l)
Remove the specified set change listener.

Specified by:
removeSetChangeListener in interface ObservableSet<E>
Parameters:
l - set change listener to remove

addVetoableSetChangeListener

public final void addVetoableSetChangeListener(VetoableSetChangeListener<E> l)
Add the specified vetoable set change listener.

Specified by:
addVetoableSetChangeListener in interface ObservableSet<E>
Parameters:
l - vetoable set change listener to add

removeVetoableSetChangeListener

public final void removeVetoableSetChangeListener(VetoableSetChangeListener<E> l)
Remove the specified vetoable set change listener.

Specified by:
removeVetoableSetChangeListener in interface ObservableSet<E>
Parameters:
l - vetoable set change listener to remove

getSetChangeListeners

public final SetChangeListener<E>[] getSetChangeListeners()
Return an array of all SetChangeListeners, or an empty array if none are registered.

Specified by:
getSetChangeListeners in interface ObservableSet<E>
Returns:
an array of all SetChangeListeners, or an empty array if none are registered

getSetChangeListenerCount

public final int getSetChangeListenerCount()
Return the number of SetChangeListeners registered to this observable set.

Specified by:
getSetChangeListenerCount in interface ObservableSet<E>
Returns:
the number of SetChangeListeners registered to this observable set

getVetoableSetChangeListeners

public final VetoableSetChangeListener<E>[] getVetoableSetChangeListeners()
Return an array of all VetoableSetChangeListeners, or an empty array if none are registered.

Specified by:
getVetoableSetChangeListeners in interface ObservableSet<E>
Returns:
an array of all VetoableSetChangeListeners, or an empty array if none are registered

getVetoableSetChangeListenerCount

public final int getVetoableSetChangeListenerCount()
Return the number of VetoableSetChangeListeners registered to this observable set.

Specified by:
getVetoableSetChangeListenerCount in interface ObservableSet<E>
Returns:
the number of VetoableSetChangeListeners registered to this observable set

fireSetWillChange

public void fireSetWillChange()
                       throws SetChangeVetoException
Fire a will change event to all registered VetoableSetChangeListeners.

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

fireSetWillChange

public void fireSetWillChange(VetoableSetChangeEvent<E> e)
                       throws SetChangeVetoException
Fire the specified will change event to all registered VetoableSetChangeListeners.

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

fireSetChanged

public void fireSetChanged()
Fire a change event to all registered SetChangeListeners.


fireSetChanged

public void fireSetChanged(SetChangeEvent<E> e)
Fire the specified change event to all registered SetChangeListeners.

Parameters:
e - change event

preAdd

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


preRemove

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


add

public boolean add(E e)

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

addAll

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

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

clear

public void clear()

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

iterator

public Iterator<E> iterator()

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

remove

public boolean remove(Object o)

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

removeAll

public boolean removeAll(Collection<?> coll)

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

retainAll

public boolean retainAll(Collection<?> coll)

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


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