vitro.util
Class ObservableList<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by vitro.util.ObservableList<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, ObservableCollection<E>

public class ObservableList<E>
extends AbstractList<E>
implements ObservableCollection<E>

An ObservableCollection implementing the List interface by way of extending AbstractList and wrapping an internal List.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ObservableList()
          Create a new, empty List.
ObservableList(Collection<? extends E> c)
          Create a new List with the same elements as another Collection.
ObservableList(Collection<? extends E> c, ObservableCollection host)
          Create a new List with the same elements as another Collection.
 
Method Summary
 void add(int i, E e)
           
 void addObserver(CollectionObserver<E> o)
          Register a CollectionObserver with this Collection.
 E get(int i)
           
 E remove(int i)
           
 E set(int i, E e)
           
 int size()
           
 List<E> store()
          Obtain a reference to the backing store used by this List.
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ObservableList

public ObservableList()
Create a new, empty List.


ObservableList

public ObservableList(Collection<? extends E> c)
Create a new List with the same elements as another Collection.

Parameters:
c - the source Collection.

ObservableList

public ObservableList(Collection<? extends E> c,
                      ObservableCollection host)
Create a new List with the same elements as another Collection. Update notifications will be sent to observers as if originating at the supplied host ObservableCollection.

Parameters:
c - the source Collection.
host - the host ObservableCollection
Method Detail

addObserver

public void addObserver(CollectionObserver<E> o)
Description copied from interface: ObservableCollection
Register a CollectionObserver with this Collection. The callbacks provided in the CollectionObserver interface will be fired whenever elements are added to or removed from this Collection.

Specified by:
addObserver in interface ObservableCollection<E>
Parameters:
o - the CollectionObserver to register.

store

public List<E> store()
Obtain a reference to the backing store used by this List. Changes to the backing store will not trigger calls to any observers of this collection.

Returns:
the internal List.

get

public E get(int i)
Specified by:
get in interface List<E>
Specified by:
get in class AbstractList<E>

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>

remove

public E remove(int i)
Specified by:
remove in interface List<E>
Overrides:
remove in class AbstractList<E>

add

public void add(int i,
                E e)
Specified by:
add in interface List<E>
Overrides:
add in class AbstractList<E>

set

public E set(int i,
             E e)
Specified by:
set in interface List<E>
Overrides:
set in class AbstractList<E>