Eclipse Platform
Release 3.3

org.eclipse.core.databinding.observable.map
Class AbstractObservableMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byorg.eclipse.core.databinding.observable.map.AbstractObservableMap
All Implemented Interfaces:
IObservable, IObservableMap, Map
Direct Known Subclasses:
ComputedObservableMap

public abstract class AbstractObservableMap
extends AbstractMap
implements IObservableMap

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

Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Constructor Summary
AbstractObservableMap()
           
AbstractObservableMap(Realm realm)
           
 
Method Summary
 void addChangeListener(IChangeListener listener)
          Adds the given change listener to the list of change listeners.
 void addMapChangeListener(IMapChangeListener listener)
           
 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.
 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  void fireChange()
          Fires change events.
protected  void fireMapChange(MapDiff diff)
          Fires map change events.
protected  void fireStale()
          Fires stale events.
protected  void firstListenerAdded()
           
 Realm getRealm()
          Returns the realm for this observable.
 boolean isStale()
          Returns whether the state of this observable is stale and is expected to change soon.
protected  void lastListenerRemoved()
           
 void removeChangeListener(IChangeListener listener)
          Removes the given change listener from the list of change listeners.
 void removeMapChangeListener(IMapChangeListener listener)
           
 void removeStaleListener(IStaleListener listener)
          Removes the given stale listener from the list of stale listeners.
 void setStale(boolean stale)
          Sets the stale state.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.databinding.observable.map.IObservableMap
containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, remove, size, values
 
Methods inherited from interface java.util.Map
clear, putAll
 

Constructor Detail

AbstractObservableMap

public AbstractObservableMap()

AbstractObservableMap

public AbstractObservableMap(Realm realm)
Parameters:
realm -
Method Detail

lastListenerRemoved

protected void lastListenerRemoved()

firstListenerAdded

protected void firstListenerAdded()

addMapChangeListener

public void addMapChangeListener(IMapChangeListener listener)
Specified by:
addMapChangeListener in interface IObservableMap
Parameters:
listener -

removeMapChangeListener

public void removeMapChangeListener(IMapChangeListener listener)
Specified by:
removeMapChangeListener in interface IObservableMap
Parameters:
listener -

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 -

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()

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

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

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.

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 -

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 -

setStale

public void setStale(boolean stale)
Sets the stale state. Must be invoked from the current realm.

Parameters:
stale -

fireStale

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


fireChange

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


fireMapChange

protected void fireMapChange(MapDiff diff)
Fires map change events. Must be invoked from current realm.

Parameters:
diff -

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.