vitro.util
Class ObservableSet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by vitro.util.ObservableSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, ObservableCollection<E>

public class ObservableSet<E>
extends AbstractSet<E>
implements ObservableCollection<E>

An ObservableCollection implementing the Set interface by way of extending AbstractSet and wrapping an internal Set.


Constructor Summary
ObservableSet()
          Create a new, empty Set.
ObservableSet(Collection<? extends E> c)
          Create a new Set with the same elements as another Collection.
ObservableSet(Collection<? extends E> c, ObservableCollection host)
          Create a new Set with the same elements as another Collection.
 
Method Summary
 boolean add(E o)
           
 void addObserver(CollectionObserver<E> o)
          Register a CollectionObserver with this Collection.
 Iterator<E> iterator()
           
 int size()
           
 Set<E> store()
          Obtain a reference to the backing store used by this Set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, 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.Set
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray
 

Constructor Detail

ObservableSet

public ObservableSet()
Create a new, empty Set.


ObservableSet

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

Parameters:
c - the source Collection.

ObservableSet

public ObservableSet(Collection<? extends E> c,
                     ObservableCollection host)
Create a new Set 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 Set<E> store()
Obtain a reference to the backing store used by this Set. Changes to the backing store will not trigger calls to any observers of this collection.

Returns:
the internal Set.

size

public int size()
Specified by:
size in interface Collection<E>
Specified by:
size in interface Set<E>
Specified by:
size in class AbstractCollection<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>
Specified by:
iterator in class AbstractCollection<E>

add

public boolean add(E o)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Set<E>
Overrides:
add in class AbstractCollection<E>