org.dishevelled.observable
Class AbstractObservableList<E>

java.lang.Object
  extended by org.dishevelled.observable.AbstractListDecorator<E>
      extended by org.dishevelled.observable.AbstractObservableList<E>
Type Parameters:
E - list element type
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, ObservableList<E>
Direct Known Subclasses:
ObservableListImpl

public abstract class AbstractObservableList<E>
extends AbstractListDecorator<E>
implements ObservableList<E>

Abstract implementation of an observable list that decorates an instance of List.

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

Nested Class Summary
protected  class AbstractObservableList.ObservableSubList
          Observable subList decorator.
 
Constructor Summary
protected AbstractObservableList(List<E> list)
          Create a new abstract observable list that decorates the specified list.
 
Method Summary
 boolean add(E e)
          
 void add(int index, E e)
          
 boolean addAll(Collection<? extends E> coll)
          
 boolean addAll(int index, Collection<? extends E> coll)
          
 void addListChangeListener(ListChangeListener<E> l)
          Add the specified list change listener.
 void addVetoableListChangeListener(VetoableListChangeListener<E> l)
          Add the specified vetoable list change listener.
 void clear()
          
 void fireListChanged()
          Fire a change event to all registered ListChangeListeners.
 void fireListChanged(ListChangeEvent<E> e)
          Fire the specified change event to all registered ListChangeListeners.
 void fireListWillChange()
          Fire a will change event to all registered VetoableListChangeListeners.
 void fireListWillChange(VetoableListChangeEvent<E> e)
          Fire the specified will change event to all registered VetoableListChangeListeners.
 int getListChangeListenerCount()
          Return the number of ListChangeListeners registered to this observable list.
 ListChangeListener<E>[] getListChangeListeners()
          Return an array of all ListChangeListeners, or an empty array if none are registered.
protected  ObservableListChangeSupport<E> getObservableListChangeSupport()
          Return the ObservableListChangeSupport class backing this abstract observable list.
 int getVetoableListChangeListenerCount()
          Return the number of VetoableListChangeListeners registered to this observable list.
 VetoableListChangeListener<E>[] getVetoableListChangeListeners()
          Return an array of all VetoableListChangeListeners, or an empty array if none are registered.
 Iterator<E> iterator()
          
 ListIterator<E> listIterator()
          
 ListIterator<E> listIterator(int index)
          
protected abstract  void postAdd(E e)
          Notify subclasses the add method has just been called on the wrapped list with the specified parameter.
protected abstract  void postAddAll(Collection<? extends E> coll)
          Notify subclasses the addAll method has just been called on the wrapped list with the specified parameter.
protected abstract  void postAddAllAtIndex(int index, Collection<? extends E> coll)
          Notify subclasses the addAll(int, Collection) method has just been called on the wrapped list with the specified parameters.
protected abstract  void postAddAtIndex(int index, E e)
          Notify subclasses the add(int, E) method has just been called on the wrapped list with the specified parameters.
protected abstract  void postClear()
          Notify subclasses the clear method has just been called on the wrapped list.
protected abstract  void postIteratorRemove()
          Notify subclasses the remove method has just been called on the wrapped list's iterator.
protected abstract  void postListIteratorRemove()
          Notify subclasses the remove method has just been called on the wrapped list's list iterator.
protected abstract  void postListIteratorSet()
          Notify subclasses the set method has just been called on the wrapped list's list iterator.
protected abstract  void postRemove(Object o)
          Notify subclasses the remove method has just been called on the wrapped list with the specified parameter.
protected abstract  void postRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method has just been called on the wrapped list with the specified parameter.
protected abstract  void postRemoveIndex(int index)
          Notify subclasses the remove(int) method has just been called on the wrapped list with the specified parameter.
protected abstract  void postRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method has just been called on the wrapped list with the specified parameter.
protected abstract  void postSet(int index, E e)
          Notify subclasses the set method has just been called on the wrapped list with the specified parameters.
protected abstract  boolean preAdd(E e)
          Notify subclasses the add method is about to be called on the wrapped list 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 list with the specified parameter.
protected abstract  boolean preAddAllAtIndex(int index, Collection<? extends E> coll)
          Notify subclasses the addAll(int, Collection) method is about to be called on the wrapped list with the specified parameters.
protected abstract  boolean preAddAtIndex(int index, E e)
          Notify subclasses the add(int, E) method is about to be called on the wrapped list with the specified parameters.
protected abstract  boolean preClear()
          Notify subclasses the clear method is about to be called on the wrapped list.
protected abstract  boolean preIteratorRemove()
          Notify subclasses the remove method is about to be called on the wrapped list's iterator.
protected abstract  boolean preListIteratorRemove()
          Notify subclasses the remove method is about to be called on the wrapped list's list iterator.
protected abstract  boolean preListIteratorSet()
          Notify subclasses the set method is about to be called on the wrapped list's list iterator.
protected abstract  boolean preRemove(Object o)
          Notify subclasses the remove method is about to be called on the wrapped list with the specified parameter.
protected abstract  boolean preRemoveAll(Collection<?> coll)
          Notify subclasses the removeAll method is about to be called on the wrapped list with the specified parameter.
protected abstract  boolean preRemoveIndex(int index)
          Notify subclasses the remove(int) method is about to be called on the wrapped list with the specified parameter.
protected abstract  boolean preRetainAll(Collection<?> coll)
          Notify subclasses the retainAll method is about to be called on the wrapped list with the specified parameter.
protected abstract  boolean preSet(int index, E e)
          Notify subclasses the set method is about to be called on the wrapped list with the specified parameters.
 E remove(int index)
          
 boolean remove(Object o)
          
 boolean removeAll(Collection<?> coll)
          
 void removeListChangeListener(ListChangeListener<E> l)
          Remove the specified list change listener.
 void removeVetoableListChangeListener(VetoableListChangeListener<E> l)
          Remove the specified vetoable list change listener.
 boolean retainAll(Collection<?> coll)
          
 E set(int index, E e)
          
 List<E> subList(int fromIndex, int toIndex)
          
 
Methods inherited from class org.dishevelled.observable.AbstractListDecorator
contains, containsAll, equals, get, getList, hashCode, indexOf, isEmpty, lastIndexOf, 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.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, lastIndexOf, size, toArray, toArray
 

Constructor Detail

AbstractObservableList

protected AbstractObservableList(List<E> list)
Create a new abstract observable list that decorates the specified list.

Parameters:
list - list to decorate
Method Detail

getObservableListChangeSupport

protected final ObservableListChangeSupport<E> getObservableListChangeSupport()
Return the ObservableListChangeSupport class backing this abstract observable list.

Returns:
the ObservableListChangeSupport class backing this abstract observable list

addListChangeListener

public final void addListChangeListener(ListChangeListener<E> l)
Add the specified list change listener.

Specified by:
addListChangeListener in interface ObservableList<E>
Parameters:
l - list change listener to add

removeListChangeListener

public final void removeListChangeListener(ListChangeListener<E> l)
Remove the specified list change listener.

Specified by:
removeListChangeListener in interface ObservableList<E>
Parameters:
l - list change listener to remove

addVetoableListChangeListener

public final void addVetoableListChangeListener(VetoableListChangeListener<E> l)
Add the specified vetoable list change listener.

Specified by:
addVetoableListChangeListener in interface ObservableList<E>
Parameters:
l - vetoable list change listener to add

removeVetoableListChangeListener

public final void removeVetoableListChangeListener(VetoableListChangeListener<E> l)
Remove the specified vetoable list change listener.

Specified by:
removeVetoableListChangeListener in interface ObservableList<E>
Parameters:
l - vetoable list change listener to remove

getListChangeListeners

public final ListChangeListener<E>[] getListChangeListeners()
Return an array of all ListChangeListeners, or an empty array if none are registered.

Specified by:
getListChangeListeners in interface ObservableList<E>
Returns:
an array of all ListChangeListeners, or an empty array if none are registered

getListChangeListenerCount

public final int getListChangeListenerCount()
Return the number of ListChangeListeners registered to this observable list.

Specified by:
getListChangeListenerCount in interface ObservableList<E>
Returns:
the number of ListChangeListeners registered to this observable list

getVetoableListChangeListeners

public final VetoableListChangeListener<E>[] getVetoableListChangeListeners()
Return an array of all VetoableListChangeListeners, or an empty array if none are registered.

Specified by:
getVetoableListChangeListeners in interface ObservableList<E>
Returns:
an array of all VetoableListChangeListeners, or an empty array if none are registered

getVetoableListChangeListenerCount

public final int getVetoableListChangeListenerCount()
Return the number of VetoableListChangeListeners registered to this observable list.

Specified by:
getVetoableListChangeListenerCount in interface ObservableList<E>
Returns:
the number of VetoableListChangeListeners registered to this observable list

fireListWillChange

public void fireListWillChange()
                        throws ListChangeVetoException
Fire a will change event to all registered VetoableListChangeListeners.

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

fireListWillChange

public void fireListWillChange(VetoableListChangeEvent<E> e)
                        throws ListChangeVetoException
Fire the specified will change event to all registered VetoableListChangeListeners.

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

fireListChanged

public void fireListChanged()
Fire a change event to all registered ListChangeListeners.


fireListChanged

public void fireListChanged(ListChangeEvent<E> e)
Fire the specified change event to all registered ListChangeListeners.

Parameters:
e - change event

preAdd

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

Parameters:
e - add method parameter

preAddAtIndex

protected abstract boolean preAddAtIndex(int index,
                                         E e)
Notify subclasses the add(int, E) method is about to be called on the wrapped list with the specified parameters. Return true to proceed with the change.

Parameters:
index - add(int, E) method index parameter
e - add(int, E) method e parameter
Returns:
true to proceed with the change

postAddAtIndex

protected abstract void postAddAtIndex(int index,
                                       E e)
Notify subclasses the add(int, E) method has just been called on the wrapped list with the specified parameters.

Parameters:
index - add(int, E) method index parameter
e - add(int, E) method e parameter

preAddAll

protected abstract boolean preAddAll(Collection<? extends E> coll)
Notify subclasses the addAll method is about to be called on the wrapped list 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 list with the specified parameter.

Parameters:
coll - addAll method parameter

preAddAllAtIndex

protected abstract boolean preAddAllAtIndex(int index,
                                            Collection<? extends E> coll)
Notify subclasses the addAll(int, Collection) method is about to be called on the wrapped list with the specified parameters. Return true to proceed with the change.

Parameters:
index - addAll(int, Collection) method index parameter
coll - addAll(int, Collection) method coll parameter
Returns:
true to proceed with the change

postAddAllAtIndex

protected abstract void postAddAllAtIndex(int index,
                                          Collection<? extends E> coll)
Notify subclasses the addAll(int, Collection) method has just been called on the wrapped list with the specified parameters.

Parameters:
index - addAll(int, Collection) method index parameter
coll - addAll(int, Collection) method coll parameter

preSet

protected abstract boolean preSet(int index,
                                  E e)
Notify subclasses the set method is about to be called on the wrapped list with the specified parameters. Return true to proceed with the change.

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

postSet

protected abstract void postSet(int index,
                                E e)
Notify subclasses the set method has just been called on the wrapped list with the specified parameters.

Parameters:
index - set method index parameter
e - set method e parameter

preClear

protected abstract boolean preClear()
Notify subclasses the clear method is about to be called on the wrapped list. 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 list.


preRemove

protected abstract boolean preRemove(Object o)
Notify subclasses the remove method is about to be called on the wrapped list 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 list with the specified parameter.

Parameters:
o - remove method parameter

preRemoveIndex

protected abstract boolean preRemoveIndex(int index)
Notify subclasses the remove(int) method is about to be called on the wrapped list with the specified parameter. Return true to proceed with the change.

Parameters:
index - remove(int) method parameter
Returns:
true to proceed with the change

postRemoveIndex

protected abstract void postRemoveIndex(int index)
Notify subclasses the remove(int) method has just been called on the wrapped list with the specified parameter.

Parameters:
index - remove(int) method parameter

preRemoveAll

protected abstract boolean preRemoveAll(Collection<?> coll)
Notify subclasses the removeAll method is about to be called on the wrapped list 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 list 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 list 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 list 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 list'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 list's iterator.


preListIteratorRemove

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

Returns:
true to proceed with the change

postListIteratorRemove

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


preListIteratorSet

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

Returns:
true to proceed with the change

postListIteratorSet

protected abstract void postListIteratorSet()
Notify subclasses the set method has just been called on the wrapped list's list iterator.


add

public boolean add(E e)

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

add

public void add(int index,
                E e)

Specified by:
add in interface List<E>
Overrides:
add in class AbstractListDecorator<E>

addAll

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

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

addAll

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

Specified by:
addAll in interface List<E>
Overrides:
addAll in class AbstractListDecorator<E>

clear

public void clear()

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

remove

public E remove(int index)

Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractListDecorator<E>

remove

public boolean remove(Object o)

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

removeAll

public boolean removeAll(Collection<?> coll)

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

retainAll

public boolean retainAll(Collection<?> coll)

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

set

public E set(int index,
             E e)

Specified by:
set in interface List<E>
Overrides:
set in class AbstractListDecorator<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 List<E>
Overrides:
iterator in class AbstractListDecorator<E>

listIterator

public ListIterator<E> listIterator()

Specified by:
listIterator in interface List<E>
Overrides:
listIterator in class AbstractListDecorator<E>

listIterator

public ListIterator<E> listIterator(int index)

Specified by:
listIterator in interface List<E>
Overrides:
listIterator in class AbstractListDecorator<E>

subList

public List<E> subList(int fromIndex,
                       int toIndex)

Specified by:
subList in interface List<E>
Overrides:
subList in class AbstractListDecorator<E>


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