Class WritableMap<K,V>
- java.lang.Object
-
- org.eclipse.core.databinding.observable.AbstractObservable
-
- org.eclipse.core.databinding.observable.map.ObservableMap<K,V>
-
- org.eclipse.core.databinding.observable.map.WritableMap<K,V>
-
- Type Parameters:
K- the type of the keys in this mapV- the type of the values in this map
- All Implemented Interfaces:
java.util.Map<K,V>,IObservable,IObservableMap<K,V>
public class WritableMap<K,V> extends ObservableMap<K,V>
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 org.eclipse.core.databinding.observable.map.ObservableMap
wrappedMap
-
-
Constructor Summary
Constructors Constructor Description WritableMap()Constructs a new WritableMap on the default realm.WritableMap(java.lang.Object keyType, java.lang.Object valueType)Constructs a new WritableMap on the default realm with the specified key and value types.WritableMap(Realm realm)Constructs a new WritableMap on the given realm.WritableMap(Realm realm, java.lang.Object keyType, java.lang.Object valueType)Constructs a new WritableMap on the given realm with the specified key and value types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddListener(java.lang.Object listenerType, IObservablesListener listener)voidclear()Clears the map.protected java.lang.Objectclone()protected voidfireEvent(ObservableEvent event)protected voidfirstListenerAdded()java.lang.ObjectgetKeyType()Returns the element type for thekeysetof this observable map, ornullif the keyset is untyped.RealmgetRealm()java.lang.ObjectgetValueType()Returns the element type for thevaluesof this observable map, ornullif the values collection is untyped.protected booleanhasListeners()protected voidlastListenerRemoved()Vput(K key, V value)Associates the providedvaluewith thekey.voidputAll(java.util.Map<? extends K,? extends V> map)Adds the providedmap's contents to this map.Vremove(java.lang.Object key)Removes the value with the providekey.protected voidremoveListener(java.lang.Object listenerType, IObservablesListener listener)-
Methods inherited from class org.eclipse.core.databinding.observable.map.ObservableMap
addMapChangeListener, containsKey, containsValue, entrySet, equals, fireMapChange, get, getterCalled, hashCode, isEmpty, isStale, keySet, removeMapChangeListener, setStale, size, values
-
Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireChange, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
-
-
-
Constructor Detail
-
WritableMap
public WritableMap()
Constructs a new WritableMap on the default realm.
-
WritableMap
public WritableMap(Realm realm)
Constructs a new WritableMap on the given realm.- Parameters:
realm- the realm
-
WritableMap
public WritableMap(java.lang.Object keyType, java.lang.Object valueType)Constructs a new WritableMap on the default realm with the specified key and value types.- Parameters:
keyType- the type of the keys in this mapvalueType- the type of the values in this map- Since:
- 1.2
-
WritableMap
public WritableMap(Realm realm, java.lang.Object keyType, java.lang.Object valueType)
Constructs a new WritableMap on the given realm with the specified key and value types.- Parameters:
realm- the realmkeyType- the type of the keys in this mapvalueType- the type of the values in this map- Since:
- 1.2
-
-
Method Detail
-
getKeyType
public java.lang.Object getKeyType()
Description copied from interface:IObservableMapReturns the element type for thekeysetof this observable map, ornullif the keyset is untyped.- Specified by:
getKeyTypein interfaceIObservableMap<K,V>- Overrides:
getKeyTypein classObservableMap<K,V>- Returns:
- the element type for the
keysetof this observable map, ornullif the keyset is untyped. - Since:
- 1.2
-
getValueType
public java.lang.Object getValueType()
Description copied from interface:IObservableMapReturns the element type for thevaluesof this observable map, ornullif the values collection is untyped.- Specified by:
getValueTypein interfaceIObservableMap<K,V>- Overrides:
getValueTypein classObservableMap<K,V>- Returns:
- the element type for the
valuesof this observable map, ornullif the values collection is untyped. - Since:
- 1.2
-
put
public V put(K key, V value)
Associates the providedvaluewith thekey. Must be invoked from the current realm.- Specified by:
putin interfaceIObservableMap<K,V>- Specified by:
putin interfacejava.util.Map<K,V>- Overrides:
putin classObservableMap<K,V>
-
remove
public V remove(java.lang.Object key)
Removes the value with the providekey. Must be invoked from the current realm.- Specified by:
removein interfaceIObservableMap<K,V>- Specified by:
removein interfacejava.util.Map<K,V>- Overrides:
removein classObservableMap<K,V>
-
clear
public void clear()
Clears the map. Must be invoked from the current realm.
-
putAll
public void putAll(java.util.Map<? extends K,? extends V> map)
Adds the providedmap's contents to this map. Must be invoked from the current realm.
-
addListener
protected void addListener(java.lang.Object listenerType, IObservablesListener listener)- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to add; notnull
-
removeListener
protected void removeListener(java.lang.Object listenerType, IObservablesListener listener)- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to remove; notnull
-
hasListeners
protected boolean hasListeners()
-
fireEvent
protected void fireEvent(ObservableEvent event)
-
firstListenerAdded
protected void firstListenerAdded()
-
lastListenerRemoved
protected void lastListenerRemoved()
-
getRealm
public Realm getRealm()
- Returns:
- Returns the realm.
-
clone
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-