Eclipse Platform
Release 3.3

org.eclipse.core.databinding.observable.list
Class AbstractObservableList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byorg.eclipse.core.databinding.observable.list.AbstractObservableList
All Implemented Interfaces:
Collection, IObservable, IObservableCollection, IObservableList, List

public abstract class AbstractObservableList
extends AbstractList
implements IObservableList

Subclasses should override at least get(int index) and size().

This class is thread safe. All state accessing methods must be invoked from the current realm. Methods for adding and removing listeners may be invoked from any thread.

Since:
1.0

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
AbstractObservableList()
           
AbstractObservableList(Realm realm)
           
 
Method Summary
 boolean add(Object o)
           
 boolean addAll(Collection c)
           
 boolean addAll(int index, Collection c)
           
 void addChangeListener(IChangeListener listener)
          Adds the given change listener to the list of change listeners.
 void addListChangeListener(IListChangeListener listener)
          Adds the given list change listener to the list of list change listeners.
 void addStaleListener(IStaleListener listener)
          Adds the given stale listener to the list of stale listeners.
protected  void checkRealm()
          Asserts that the realm is the current realm.
 boolean contains(Object o)
           
 boolean containsAll(Collection c)
           
 void dispose()
          Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.
protected abstract  int doGetSize()
           
 boolean equals(Object o)
           
protected  void fireChange()
          Fires change event.
protected  void fireListChange(ListDiff diff)
           
protected  void fireStale()
          Fires stale event.
protected  void firstListenerAdded()
           
 Realm getRealm()
          Returns the realm for this observable.
 int hashCode()
           
 int indexOf(Object o)
           
 boolean isEmpty()
           
 boolean isStale()
          Returns whether the state of this observable is stale and is expected to change soon.
 Iterator iterator()
           
 int lastIndexOf(Object o)
           
protected  void lastListenerRemoved()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection c)
           
 void removeChangeListener(IChangeListener listener)
          Removes the given change listener from the list of change listeners.
 void removeListChangeListener(IListChangeListener listener)
          Removes the given list change listener from the list of list change listeners.
 void removeStaleListener(IStaleListener listener)
          Removes the given stale listener from the list of stale listeners.
 boolean retainAll(Collection c)
           
 int size()
           
 Object[] toArray()
           
 Object[] toArray(Object[] a)
           
 
Methods inherited from class java.util.AbstractList
add, clear, get, listIterator, listIterator, remove, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.databinding.observable.list.IObservableList
get, getElementType, listIterator, listIterator, remove, set, subList
 
Methods inherited from interface java.util.List
add, clear
 

Constructor Detail

AbstractObservableList

public AbstractObservableList(Realm realm)
Parameters:
realm -

AbstractObservableList

public AbstractObservableList()
Method Detail

isStale

public boolean isStale()
Description copied from interface: IObservable
Returns whether the state of this observable is stale and is expected to change soon. A non-stale observable that becomes stale will notify its stale listeners. A stale object that becomes non-stale does so by changing its state and notifying its change listeners, it does not notify its stale listeners about becoming non-stale. Clients that do not expect asynchronous changes may ignore staleness of observable objects.

Specified by:
isStale in interface IObservable
Returns:
true if this observable's state is stale and will change soon.

addListChangeListener

public void addListChangeListener(IListChangeListener listener)
Description copied from interface: IObservableList
Adds the given list change listener to the list of list change listeners.

Specified by:
addListChangeListener in interface IObservableList
Parameters:
listener -

removeListChangeListener

public void removeListChangeListener(IListChangeListener listener)
Description copied from interface: IObservableList
Removes the given list change listener from the list of list change listeners. Has no effect if the given listener is not registered as a list change listener.

Specified by:
removeListChangeListener in interface IObservableList
Parameters:
listener -

fireListChange

protected void fireListChange(ListDiff diff)

addChangeListener

public void addChangeListener(IChangeListener listener)
Description copied from interface: IObservable
Adds the given change listener to the list of change listeners. Change listeners are notified about changes of the state of this observable in a generic way, without specifying the change that happened. To get the changed state, a change listener needs to query for the current state of this observable.

Specified by:
addChangeListener in interface IObservable
Parameters:
listener -

removeChangeListener

public void removeChangeListener(IChangeListener listener)
Description copied from interface: IObservable
Removes the given change listener from the list of change listeners. Has no effect if the given listener is not registered as a change listener.

Specified by:
removeChangeListener in interface IObservable
Parameters:
listener -

addStaleListener

public void addStaleListener(IStaleListener listener)
Description copied from interface: IObservable
Adds the given stale listener to the list of stale listeners. Stale listeners are notified when an observable object becomes stale, not when is becomes non-stale.

Specified by:
addStaleListener in interface IObservable
Parameters:
listener -
See Also:
IObservable.isStale()

removeStaleListener

public void removeStaleListener(IStaleListener listener)
Description copied from interface: IObservable
Removes the given stale listener from the list of stale listeners. Has no effect if the given listener is not registered as a stale listener.

Specified by:
removeStaleListener in interface IObservable
Parameters:
listener -

fireChange

protected void fireChange()
Fires change event. Must be invoked from the current realm.


fireStale

protected void fireStale()
Fires stale event. Must be invoked from the current realm.


firstListenerAdded

protected void firstListenerAdded()

lastListenerRemoved

protected void lastListenerRemoved()

dispose

public void dispose()
Description copied from interface: IObservable
Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.

Specified by:
dispose in interface IObservable

size

public final int size()
Specified by:
size in interface IObservableList

doGetSize

protected abstract int doGetSize()
Returns:
the size

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface IObservableList

contains

public boolean contains(Object o)
Specified by:
contains in interface IObservableList

iterator

public Iterator iterator()
Specified by:
iterator in interface IObservableList

toArray

public Object[] toArray()
Specified by:
toArray in interface IObservableList

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface IObservableList

add

public boolean add(Object o)
Specified by:
add in interface IObservableList

remove

public boolean remove(Object o)
Specified by:
remove in interface IObservableList

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface IObservableList

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface IObservableList

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface IObservableList

removeAll

public boolean removeAll(Collection c)
Specified by:
removeAll in interface IObservableList

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface IObservableList

equals

public boolean equals(Object o)
Specified by:
equals in interface IObservableList

hashCode

public int hashCode()
Specified by:
hashCode in interface IObservableList

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface IObservableList

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface IObservableList

getRealm

public Realm getRealm()
Description copied from interface: IObservable
Returns the realm for this observable. Unless otherwise specified, getters and setters must be accessed from within this realm. Listeners will be within this realm when they receive events from this observable.

Because observables can only be accessed from within one realm, and they always fire events on that realm, their state can be observed in an incremental way. It is always safe to call getters of an observable from within a change listener attached to that observable.

Specified by:
getRealm in interface IObservable
Returns:
the realm

checkRealm

protected void checkRealm()
Asserts that the realm is the current realm.

Throws:
AssertionFailedException - if the realm is not the current realm
See Also:
Realm.isCurrent()

Eclipse Platform
Release 3.3

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2007. All rights reserved.