org.dishevelled.observable
Class AbstractObservableMap<K,V>

java.lang.Object
  extended by org.dishevelled.observable.AbstractMapDecorator<K,V>
      extended by org.dishevelled.observable.AbstractObservableMap<K,V>
Type Parameters:
K - map key type
V - map value type
All Implemented Interfaces:
Map<K,V>, ObservableMap<K,V>
Direct Known Subclasses:
ObservableMapImpl

public abstract class AbstractObservableMap<K,V>
extends AbstractMapDecorator<K,V>
implements ObservableMap<K,V>

Abstract implementation of an observable map that decorates an instance of Map.

Version:
$Revision$ $Date$
Author:
Michael Heuer

Nested Class Summary
protected  class AbstractObservableMap.ObservableEntrySet
          Observable entrySet view decorator.
protected  class AbstractObservableMap.ObservableKeySet
          Observable keySet view decorator.
protected  class AbstractObservableMap.ObservableValues
          Observable values view decorator.
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
protected AbstractObservableMap(Map<K,V> map)
          Create a new abstract observable map that decorates the specified map.
 
Method Summary
 void addMapChangeListener(MapChangeListener<K,V> l)
          Add the specified map change listener.
 void addVetoableMapChangeListener(VetoableMapChangeListener<K,V> l)
          Add the specified vetoable map change listener.
 void clear()
          
 Set<Map.Entry<K,V>> entrySet()
          
 void fireMapChanged()
          Fire a change event to all registered MapChangeListeners.
 void fireMapChanged(MapChangeEvent<K,V> e)
          Fire the specified change event to all registered MapChangeListeners.
 void fireMapWillChange()
          Fire a will change event to all registered VetoableMapChangeListeners.
 void fireMapWillChange(VetoableMapChangeEvent<K,V> e)
          Fire the specified will change event to all registered VetoableMapChangeListeners.
 int getMapChangeListenerCount()
          Return the number of MapChangeListeners registered to this observable map.
 MapChangeListener<K,V>[] getMapChangeListeners()
          Return an array of all MapChangeListeners, or an empty array if none are registered.
protected  ObservableMapChangeSupport<K,V> getObservableMapChangeSupport()
          Return the ObservableMapChangeSupport class backing this abstract observable map.
 int getVetoableMapChangeListenerCount()
          Return the number of VetoableMapChangeListeners registered to this observable map.
 VetoableMapChangeListener<K,V>[] getVetoableMapChangeListeners()
          Return an array of all VetoableMapChangeListeners, or an empty array if none are registered.
 Set<K> keySet()
          
protected abstract  void postClear()
          Notify subclasses the clear method has just been called on the wrapped map.
protected abstract  void postEntrySetClear()
          Notify subclasses the clear method has just been called on the entrySet view for the wrapped map with the specified parameter.
protected abstract  void postEntrySetIteratorRemove()
          Notify subclasses the remove method has just been called on the entrySet view iterator for the wrapped map.
protected abstract  void postEntrySetRemove(Object value)
          Notify subclasses the remove method has just been called on the entrySet view for the wrapped map with the specified parameter.
protected abstract  void postEntrySetRemoveAll(Collection<?> entrySet)
          Notify subclasses the removeAll method has just been called on the entrySet view for the wrapped map with the specified parameter.
protected abstract  void postEntrySetRetainAll(Collection<?> entrySet)
          Notify subclasses the clear method has just been called on the entrySet view for the wrapped map with the specified parameter.
protected abstract  void postKeySetClear()
          Notify subclasses the clear method has just been called on the keySet view for the wrapped map with the specified parameter.
protected abstract  void postKeySetIteratorRemove()
          Notify subclasses the remove method has just been called on the keySet view iterator for the wrapped map.
protected abstract  void postKeySetRemove(Object value)
          Notify subclasses the remove method has just been called on the keySet view for the wrapped map with the specified parameter.
protected abstract  void postKeySetRemoveAll(Collection<?> keySet)
          Notify subclasses the removeAll method has just been called on the keySet view for the wrapped map with the specified parameter.
protected abstract  void postKeySetRetainAll(Collection<?> keySet)
          Notify subclasses the clear method has just been called on the keySet view for the wrapped map with the specified parameter.
protected abstract  void postMapEntrySetValue(V value)
          Notify subclasses the setValue method has just been called on a map entry from the entrySet view iterator for the wrapped map.
protected abstract  void postPut(K key, V value)
          Notify subclasses the put method has just been called on the wrapped map with the specified parameters.
protected abstract  void postPutAll(Map<? extends K,? extends V> map)
          Notify subclasses the putAll method has just been called on the wrapped map with the specified parameter.
protected abstract  void postRemove(Object key)
          Notify subclasses the remove method has just been called on the wrapped map with the specified parameter.
protected abstract  void postValuesClear()
          Notify subclasses the clear method has just been called on the values view for the wrapped map with the specified parameter.
protected abstract  void postValuesIteratorRemove()
          Notify subclasses the remove method has just been called on the values view iterator for the wrapped map.
protected abstract  void postValuesRemove(Object value)
          Notify subclasses the remove method has just been called on the values view for the wrapped map with the specified parameter.
protected abstract  void postValuesRemoveAll(Collection<?> values)
          Notify subclasses the removeAll method has just been called on the values view for the wrapped map with the specified parameter.
protected abstract  void postValuesRetainAll(Collection<?> values)
          Notify subclasses the clear method has just been called on the values view for the wrapped map with the specified parameter.
protected abstract  boolean preClear()
          Notify subclasses the clear method is about to be called on the wrapped map.
protected abstract  boolean preEntrySetClear()
          Notify subclasses the clear method is about to be called on the entrySet view for the wrapped map.
protected abstract  boolean preEntrySetIteratorRemove()
          Notify subclasses the remove method is about to be called on the entrySet view iterator for the wrapped map.
protected abstract  boolean preEntrySetRemove(Object value)
          Notify subclasses the remove method is about to be called on the entrySet view for the wrapped map.
protected abstract  boolean preEntrySetRemoveAll(Collection<?> entrySet)
          Notify subclasses the removeAll method is about to be called on the entrySet view for the wrapped map.
protected abstract  boolean preEntrySetRetainAll(Collection<?> entrySet)
          Notify subclasses the retainAll method is about to be called on the entrySet view for the wrapped map.
protected abstract  boolean preKeySetClear()
          Notify subclasses the clear method is about to be called on the keySet view for the wrapped map.
protected abstract  boolean preKeySetIteratorRemove()
          Notify subclasses the remove method is about to be called on the keySet view iterator for the wrapped map.
protected abstract  boolean preKeySetRemove(Object value)
          Notify subclasses the remove method is about to be called on the keySet view for the wrapped map.
protected abstract  boolean preKeySetRemoveAll(Collection<?> keySet)
          Notify subclasses the removeAll method is about to be called on the keySet view for the wrapped map.
protected abstract  boolean preKeySetRetainAll(Collection<?> keySet)
          Notify subclasses the retainAll method is about to be called on the keySet view for the wrapped map.
protected abstract  boolean preMapEntrySetValue(V value)
          Notify subclasses the setValue method is about to be called on a map entry from the entrySet view iterator for the wrapped map.
protected abstract  boolean prePut(K key, V value)
          Notify subclasses the put method is about to be called on the wrapped map with the specified parameters.
protected abstract  boolean prePutAll(Map<? extends K,? extends V> map)
          Notify subclasses the putAll method is about to be called on the wrapped map with the specified parameter.
protected abstract  boolean preRemove(Object key)
          Notify subclasses the remove method is about to be called on the wrapped map with the specified parameter.
protected abstract  boolean preValuesClear()
          Notify subclasses the clear method is about to be called on the values view for the wrapped map.
protected abstract  boolean preValuesIteratorRemove()
          Notify subclasses the remove method is about to be called on the values view iterator for the wrapped map.
protected abstract  boolean preValuesRemove(Object value)
          Notify subclasses the remove method is about to be called on the values view for the wrapped map.
protected abstract  boolean preValuesRemoveAll(Collection<?> values)
          Notify subclasses the removeAll method is about to be called on the values view for the wrapped map.
protected abstract  boolean preValuesRetainAll(Collection<?> values)
          Notify subclasses the retainAll method is about to be called on the values view for the wrapped map.
 V put(K key, V value)
          
 void putAll(Map<? extends K,? extends V> map)
          
 V remove(Object key)
          
 void removeMapChangeListener(MapChangeListener<K,V> l)
          Remove the specified map change listener.
 void removeVetoableMapChangeListener(VetoableMapChangeListener<K,V> l)
          Remove the specified vetoable map change listener.
 Collection<V> values()
          
 
Methods inherited from class org.dishevelled.observable.AbstractMapDecorator
containsKey, containsValue, equals, get, getMap, hashCode, isEmpty, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, containsValue, equals, get, hashCode, isEmpty, size
 

Constructor Detail

AbstractObservableMap

protected AbstractObservableMap(Map<K,V> map)
Create a new abstract observable map that decorates the specified map.

Parameters:
map - map to decorate
Method Detail

getObservableMapChangeSupport

protected final ObservableMapChangeSupport<K,V> getObservableMapChangeSupport()
Return the ObservableMapChangeSupport class backing this abstract observable map.

Returns:
the ObservableMapChangeSupport class backing this abstract observable map

addMapChangeListener

public final void addMapChangeListener(MapChangeListener<K,V> l)
Add the specified map change listener.

Specified by:
addMapChangeListener in interface ObservableMap<K,V>
Parameters:
l - map change listener to add

removeMapChangeListener

public final void removeMapChangeListener(MapChangeListener<K,V> l)
Remove the specified map change listener.

Specified by:
removeMapChangeListener in interface ObservableMap<K,V>
Parameters:
l - map change listener to remove

addVetoableMapChangeListener

public final void addVetoableMapChangeListener(VetoableMapChangeListener<K,V> l)
Add the specified vetoable map change listener.

Specified by:
addVetoableMapChangeListener in interface ObservableMap<K,V>
Parameters:
l - vetoable map change listener to add

removeVetoableMapChangeListener

public final void removeVetoableMapChangeListener(VetoableMapChangeListener<K,V> l)
Remove the specified vetoable map change listener.

Specified by:
removeVetoableMapChangeListener in interface ObservableMap<K,V>
Parameters:
l - vetoable map change listener to remove

getMapChangeListeners

public final MapChangeListener<K,V>[] getMapChangeListeners()
Return an array of all MapChangeListeners, or an empty array if none are registered.

Specified by:
getMapChangeListeners in interface ObservableMap<K,V>
Returns:
an array of all MapChangeListeners, or an empty array if none are registered

getMapChangeListenerCount

public final int getMapChangeListenerCount()
Return the number of MapChangeListeners registered to this observable map.

Specified by:
getMapChangeListenerCount in interface ObservableMap<K,V>
Returns:
the number of MapChangeListeners registered to this observable map

getVetoableMapChangeListeners

public final VetoableMapChangeListener<K,V>[] getVetoableMapChangeListeners()
Return an array of all VetoableMapChangeListeners, or an empty array if none are registered.

Specified by:
getVetoableMapChangeListeners in interface ObservableMap<K,V>
Returns:
an array of all VetoableMapChangeListeners, or an empty array if none are registered

getVetoableMapChangeListenerCount

public final int getVetoableMapChangeListenerCount()
Return the number of VetoableMapChangeListeners registered to this observable map.

Specified by:
getVetoableMapChangeListenerCount in interface ObservableMap<K,V>
Returns:
the number of VetoableMapChangeListeners registered to this observable map

fireMapWillChange

public void fireMapWillChange()
                       throws MapChangeVetoException
Fire a will change event to all registered VetoableMapChangeListeners.

Throws:
MapChangeVetoException - if any of the listeners veto the change

fireMapWillChange

public void fireMapWillChange(VetoableMapChangeEvent<K,V> e)
                       throws MapChangeVetoException
Fire the specified will change event to all registered VetoableMapChangeListeners.

Parameters:
e - will change event
Throws:
MapChangeVetoException - if any of the listeners veto the change

fireMapChanged

public void fireMapChanged()
Fire a change event to all registered MapChangeListeners.


fireMapChanged

public void fireMapChanged(MapChangeEvent<K,V> e)
Fire the specified change event to all registered MapChangeListeners.

Parameters:
e - change event

preClear

protected abstract boolean preClear()
Notify subclasses the clear method is about to be called on the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postClear

protected abstract void postClear()
Notify subclasses the clear method has just been called on the wrapped map.


prePut

protected abstract boolean prePut(K key,
                                  V value)
Notify subclasses the put method is about to be called on the wrapped map with the specified parameters. Return true to proceed with the change.

Parameters:
key - put method key parameter
value - put method value parameter
Returns:
true to proceed with the change

postPut

protected abstract void postPut(K key,
                                V value)
Notify subclasses the put method has just been called on the wrapped map with the specified parameters.

Parameters:
key - put method key parameter
value - put method value parameter

prePutAll

protected abstract boolean prePutAll(Map<? extends K,? extends V> map)
Notify subclasses the putAll method is about to be called on the wrapped map with the specified parameter. Return true to proceed with the change.

Parameters:
map - putAll method parameter
Returns:
true to proceed with the change

postPutAll

protected abstract void postPutAll(Map<? extends K,? extends V> map)
Notify subclasses the putAll method has just been called on the wrapped map with the specified parameter.

Parameters:
map - putAll method parameter

preRemove

protected abstract boolean preRemove(Object key)
Notify subclasses the remove method is about to be called on the wrapped map with the specified parameter. Return true to proceed with the change.

Parameters:
key - remove method parameter
Returns:
true to proceed with the change

postRemove

protected abstract void postRemove(Object key)
Notify subclasses the remove method has just been called on the wrapped map with the specified parameter.

Parameters:
key - remove method parameter

preValuesClear

protected abstract boolean preValuesClear()
Notify subclasses the clear method is about to be called on the values view for the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postValuesClear

protected abstract void postValuesClear()
Notify subclasses the clear method has just been called on the values view for the wrapped map with the specified parameter.


preValuesRemove

protected abstract boolean preValuesRemove(Object value)
Notify subclasses the remove method is about to be called on the values view for the wrapped map. Return true to proceed with the change.

Parameters:
value - remove method parameter
Returns:
true to proceed with the change

postValuesRemove

protected abstract void postValuesRemove(Object value)
Notify subclasses the remove method has just been called on the values view for the wrapped map with the specified parameter.

Parameters:
value - remove method parameter

preValuesRemoveAll

protected abstract boolean preValuesRemoveAll(Collection<?> values)
Notify subclasses the removeAll method is about to be called on the values view for the wrapped map. Return true to proceed with the change.

Parameters:
values - removeAll method parameter
Returns:
true to proceed with the change

postValuesRemoveAll

protected abstract void postValuesRemoveAll(Collection<?> values)
Notify subclasses the removeAll method has just been called on the values view for the wrapped map with the specified parameter.

Parameters:
values - removeAll method parameter

preValuesRetainAll

protected abstract boolean preValuesRetainAll(Collection<?> values)
Notify subclasses the retainAll method is about to be called on the values view for the wrapped map. Return true to proceed with the change.

Parameters:
values - retainAll method parameter
Returns:
true to proceed with the change

postValuesRetainAll

protected abstract void postValuesRetainAll(Collection<?> values)
Notify subclasses the clear method has just been called on the values view for the wrapped map with the specified parameter.

Parameters:
values - retainAll method parameter

preValuesIteratorRemove

protected abstract boolean preValuesIteratorRemove()
Notify subclasses the remove method is about to be called on the values view iterator for the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postValuesIteratorRemove

protected abstract void postValuesIteratorRemove()
Notify subclasses the remove method has just been called on the values view iterator for the wrapped map.


preKeySetClear

protected abstract boolean preKeySetClear()
Notify subclasses the clear method is about to be called on the keySet view for the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postKeySetClear

protected abstract void postKeySetClear()
Notify subclasses the clear method has just been called on the keySet view for the wrapped map with the specified parameter.


preKeySetRemove

protected abstract boolean preKeySetRemove(Object value)
Notify subclasses the remove method is about to be called on the keySet view for the wrapped map. Return true to proceed with the change.

Parameters:
value - remove method parameter
Returns:
true to proceed with the change

postKeySetRemove

protected abstract void postKeySetRemove(Object value)
Notify subclasses the remove method has just been called on the keySet view for the wrapped map with the specified parameter.

Parameters:
value - remove method parameter

preKeySetRemoveAll

protected abstract boolean preKeySetRemoveAll(Collection<?> keySet)
Notify subclasses the removeAll method is about to be called on the keySet view for the wrapped map. Return true to proceed with the change.

Parameters:
keySet - removeAll method parameter
Returns:
true to proceed with the change

postKeySetRemoveAll

protected abstract void postKeySetRemoveAll(Collection<?> keySet)
Notify subclasses the removeAll method has just been called on the keySet view for the wrapped map with the specified parameter.

Parameters:
keySet - removeAll method parameter

preKeySetRetainAll

protected abstract boolean preKeySetRetainAll(Collection<?> keySet)
Notify subclasses the retainAll method is about to be called on the keySet view for the wrapped map. Return true to proceed with the change.

Parameters:
keySet - retainAll method parameter
Returns:
true to proceed with the change

postKeySetRetainAll

protected abstract void postKeySetRetainAll(Collection<?> keySet)
Notify subclasses the clear method has just been called on the keySet view for the wrapped map with the specified parameter.

Parameters:
keySet - retainAll method parameter

preKeySetIteratorRemove

protected abstract boolean preKeySetIteratorRemove()
Notify subclasses the remove method is about to be called on the keySet view iterator for the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postKeySetIteratorRemove

protected abstract void postKeySetIteratorRemove()
Notify subclasses the remove method has just been called on the keySet view iterator for the wrapped map.


preEntrySetClear

protected abstract boolean preEntrySetClear()
Notify subclasses the clear method is about to be called on the entrySet view for the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postEntrySetClear

protected abstract void postEntrySetClear()
Notify subclasses the clear method has just been called on the entrySet view for the wrapped map with the specified parameter.


preEntrySetRemove

protected abstract boolean preEntrySetRemove(Object value)
Notify subclasses the remove method is about to be called on the entrySet view for the wrapped map. Return true to proceed with the change.

Parameters:
value - remove method parameter
Returns:
true to proceed with the change

postEntrySetRemove

protected abstract void postEntrySetRemove(Object value)
Notify subclasses the remove method has just been called on the entrySet view for the wrapped map with the specified parameter.

Parameters:
value - remove method parameter

preEntrySetRemoveAll

protected abstract boolean preEntrySetRemoveAll(Collection<?> entrySet)
Notify subclasses the removeAll method is about to be called on the entrySet view for the wrapped map. Return true to proceed with the change.

Parameters:
entrySet - removeAll method parameter
Returns:
true to proceed with the change

postEntrySetRemoveAll

protected abstract void postEntrySetRemoveAll(Collection<?> entrySet)
Notify subclasses the removeAll method has just been called on the entrySet view for the wrapped map with the specified parameter.

Parameters:
entrySet - removeAll method parameter

preEntrySetRetainAll

protected abstract boolean preEntrySetRetainAll(Collection<?> entrySet)
Notify subclasses the retainAll method is about to be called on the entrySet view for the wrapped map. Return true to proceed with the change.

Parameters:
entrySet - retainAll method parameter
Returns:
true to proceed with the change

postEntrySetRetainAll

protected abstract void postEntrySetRetainAll(Collection<?> entrySet)
Notify subclasses the clear method has just been called on the entrySet view for the wrapped map with the specified parameter.

Parameters:
entrySet - retainAll method parameter

preEntrySetIteratorRemove

protected abstract boolean preEntrySetIteratorRemove()
Notify subclasses the remove method is about to be called on the entrySet view iterator for the wrapped map. Return true to proceed with the change.

Returns:
true to proceed with the change

postEntrySetIteratorRemove

protected abstract void postEntrySetIteratorRemove()
Notify subclasses the remove method has just been called on the entrySet view iterator for the wrapped map.


preMapEntrySetValue

protected abstract boolean preMapEntrySetValue(V value)
Notify subclasses the setValue method is about to be called on a map entry from the entrySet view iterator for the wrapped map. Return true to proceed with the change.

Parameters:
value - setValue method parameter
Returns:
true to proceed with the change

postMapEntrySetValue

protected abstract void postMapEntrySetValue(V value)
Notify subclasses the setValue method has just been called on a map entry from the entrySet view iterator for the wrapped map.

Parameters:
value - setValue method parameter

clear

public void clear()

Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMapDecorator<K,V>

put

public V put(K key,
             V value)

Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMapDecorator<K,V>

putAll

public void putAll(Map<? extends K,? extends V> map)

Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class AbstractMapDecorator<K,V>

remove

public V remove(Object key)

Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMapDecorator<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()

Specified by:
entrySet in interface Map<K,V>
Overrides:
entrySet in class AbstractMapDecorator<K,V>

keySet

public Set<K> keySet()

Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class AbstractMapDecorator<K,V>

values

public Collection<V> values()

Specified by:
values in interface Map<K,V>
Overrides:
values in class AbstractMapDecorator<K,V>


Copyright (c) 2003-2012 held jointly by the individual authors. Licensed under the GNU Lesser General Public License (LGPL).