org.norther.tammi.acorn.util
Class ModifiableMap<K,V>

java.lang.Object
  extended by org.norther.tammi.acorn.util.UnmodifiableMap<K,V>
      extended by org.norther.tammi.acorn.util.ModifiableMap<K,V>
Type Parameters:
K - the type of keys maintained by this map.
V - the type of mapped values.
All Implemented Interfaces:
Serializable, Cloneable, ConcurrentMap<K,V>, Map<K,V>, SortedMap<K,V>, Modifiable

public class ModifiableMap<K,V>
extends UnmodifiableMap<K,V>
implements Modifiable

Extends UnmodifiableMap by supporting modifications after cloning.

Version:
$Id: ModifiableMap.java,v 1.17 2009/10/29 21:44:08 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from interface org.norther.tammi.acorn.util.Modifiable
MODIFIABLE_ADAPTEE, MODIFIABLE_ADAPTER, MODIFIABLE_COLLECTION, MODIFIABLE_MASK
 
Constructor Summary
ModifiableMap(boolean... modifiable)
          Constructs an empty map.
ModifiableMap(Map<K,V> m, boolean... modifiable)
          Constructs a new map.
 
Method Summary
 void clear()
           
 Object clone()
           
 Set<Map.Entry<K,V>> entrySet()
           
protected  Map<K,V> getModifiableMap(boolean... modifiable)
          Gets a modifiable instance of the wrapped map.
 boolean isModifiable()
          Checks whether this collection is modifiable.
 Set<K> keySet()
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> x)
           
 V putIfAbsent(K key, V value)
           
 V remove(Object key)
           
 boolean remove(Object key, Object value)
           
 V replace(K key, V value)
           
 boolean replace(K key, V oldValue, V newValue)
           
protected  void setMap(Map<K,V> m)
          Sets the map adaptee.
 Collection<V> values()
           
 
Methods inherited from class org.norther.tammi.acorn.util.UnmodifiableMap
comparator, containsKey, containsValue, equals, firstKey, get, getMap, hashCode, headMap, isEmpty, lastKey, size, subMap, tailMap, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModifiableMap

public ModifiableMap(boolean... modifiable)
Constructs an empty map.

Parameters:
modifiable - the modifiable states of the collection, adapter and adaptee.

ModifiableMap

public ModifiableMap(Map<K,V> m,
                     boolean... modifiable)
Constructs a new map.

Parameters:
m - a map to wrap.
modifiable - the modifiable states of the collection, adapter and adaptee.
Method Detail

clone

public Object clone()
Overrides:
clone in class UnmodifiableMap<K,V>

isModifiable

public boolean isModifiable()
Description copied from interface: Modifiable
Checks whether this collection is modifiable.

Specified by:
isModifiable in interface Modifiable
Returns:
true for a modifiable collection, false otherwise.

clear

public void clear()
Specified by:
clear in interface Map<K,V>
Overrides:
clear in class UnmodifiableMap<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in interface SortedMap<K,V>
Overrides:
entrySet in class UnmodifiableMap<K,V>

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>
Specified by:
keySet in interface SortedMap<K,V>
Overrides:
keySet in class UnmodifiableMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class UnmodifiableMap<K,V>

putAll

public void putAll(Map<? extends K,? extends V> x)
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class UnmodifiableMap<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class UnmodifiableMap<K,V>

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>
Specified by:
values in interface SortedMap<K,V>
Overrides:
values in class UnmodifiableMap<K,V>

putIfAbsent

public V putIfAbsent(K key,
                     V value)
Specified by:
putIfAbsent in interface ConcurrentMap<K,V>
Overrides:
putIfAbsent in class UnmodifiableMap<K,V>

replace

public V replace(K key,
                 V value)
Specified by:
replace in interface ConcurrentMap<K,V>
Overrides:
replace in class UnmodifiableMap<K,V>

replace

public boolean replace(K key,
                       V oldValue,
                       V newValue)
Specified by:
replace in interface ConcurrentMap<K,V>
Overrides:
replace in class UnmodifiableMap<K,V>

remove

public boolean remove(Object key,
                      Object value)
Specified by:
remove in interface ConcurrentMap<K,V>
Overrides:
remove in class UnmodifiableMap<K,V>

setMap

protected void setMap(Map<K,V> m)
Description copied from class: UnmodifiableMap
Sets the map adaptee.

Overrides:
setMap in class UnmodifiableMap<K,V>
Parameters:
m - the wrapped map.

getModifiableMap

protected Map<K,V> getModifiableMap(boolean... modifiable)
Gets a modifiable instance of the wrapped map.

Parameters:
modifiable - the modifiable states of the collection, adapter and adaptee.
Returns:
a modifiable map or null.


Copyright © 2004 The Norther Organization. All rights reserved.