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.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
AbstractObservableMap() |
AbstractObservableMap(Realm realm) |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(IChangeListener listener)
Adds the given change listener to the list of change listeners.
|
void |
addDisposeListener(IDisposeListener listener)
Adds the given dispose listener to the list of dispose 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() |
Object |
getKeyType()
Returns the element type for the
keyset of this
observable map, or null if the keyset is untyped. |
Realm |
getRealm()
Returns the realm for this observable.
|
Object |
getValueType()
Returns the element type for the
values of this
observable map, or null if the values collection is untyped. |
protected boolean |
hasListeners() |
boolean |
isDisposed()
Returns whether the observable has been disposed
|
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 |
removeDisposeListener(IDisposeListener listener)
Removes the given dispose listener from the list of dispose 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.
|
clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
finalize, getClass, notify, notifyAll, wait, wait, wait
containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, remove, size, values
public AbstractObservableMap()
public AbstractObservableMap(Realm realm)
realm
- protected void lastListenerRemoved()
protected void firstListenerAdded()
public void addMapChangeListener(IMapChangeListener listener)
addMapChangeListener
in interface IObservableMap
public void removeMapChangeListener(IMapChangeListener listener)
removeMapChangeListener
in interface IObservableMap
public void addChangeListener(IChangeListener listener)
IObservable
addChangeListener
in interface IObservable
public void addStaleListener(IStaleListener listener)
IObservable
addStaleListener
in interface IObservable
IObservable.isStale()
protected boolean hasListeners()
public void addDisposeListener(IDisposeListener listener)
IObservable
addDisposeListener
in interface IObservable
listener
- the listener to addpublic void removeDisposeListener(IDisposeListener listener)
IObservable
removeDisposeListener
in interface IObservable
listener
- the listener to removepublic boolean isDisposed()
IObservable
isDisposed
in interface IObservable
public void dispose()
IObservable
dispose
in interface IObservable
public Realm getRealm()
IObservable
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.
getRealm
in interface IObservable
public boolean isStale()
IObservable
isStale
in interface IObservable
public Object getKeyType()
IObservableMap
keyset
of this
observable map, or null
if the keyset is untyped.getKeyType
in interface IObservableMap
keyset
of this
observable map, or null
if the keyset is untyped.public Object getValueType()
IObservableMap
values
of this
observable map, or null
if the values collection is untyped.getValueType
in interface IObservableMap
values
of this
observable map, or null
if the values collection is
untyped.public void removeChangeListener(IChangeListener listener)
IObservable
removeChangeListener
in interface IObservable
public void removeStaleListener(IStaleListener listener)
IObservable
removeStaleListener
in interface IObservable
public void setStale(boolean stale)
stale
- protected void fireStale()
protected void fireChange()
protected void fireMapChange(MapDiff diff)
diff
- protected void checkRealm()
AssertionFailedException
- if the realm is not the current realmRealm.isCurrent()
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.