Apache Tomcat 6.0.53

org.apache.catalina.util
Class ParameterMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by java.util.LinkedHashMap<K,V>
              extended by org.apache.catalina.util.ParameterMap<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,V>

public final class ParameterMap<K,V>
extends java.util.LinkedHashMap<K,V>

Extended implementation of HashMap that includes a locked property. This class can be used to safely expose Catalina internal parameter map objects to user classes without having to clone them in order to avoid modifications. When first created, a ParmaeterMap instance is not locked.

Author:
Craig R. McClanahan
See Also:
Serialized Form

Constructor Summary
ParameterMap()
          Construct a new, empty map with the default initial capacity and load factor.
ParameterMap(int initialCapacity)
          Construct a new, empty map with the specified initial capacity and default load factor.
ParameterMap(int initialCapacity, float loadFactor)
          Construct a new, empty map with the specified initial capacity and load factor.
ParameterMap(java.util.Map<K,V> map)
          Construct a new map with the same mappings as the given map.
 
Method Summary
 void clear()
          Remove all mappings from this map.
 boolean isLocked()
          Return the locked state of this parameter map.
 V put(K key, V value)
          Associate the specified value with the specified key in this map.
 void putAll(java.util.Map<? extends K,? extends V> map)
          Copy all of the mappings from the specified map to this one.
 V remove(java.lang.Object key)
          Remove the mapping for this key from the map if present.
 void setLocked(boolean locked)
          Set the locked state of this parameter map.
 
Methods inherited from class java.util.LinkedHashMap
containsValue, get, removeEldestEntry
 
Methods inherited from class java.util.HashMap
clone, containsKey, entrySet, isEmpty, keySet, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsKey, entrySet, equals, hashCode, isEmpty, keySet, size, values
 

Constructor Detail

ParameterMap

public ParameterMap()
Construct a new, empty map with the default initial capacity and load factor.


ParameterMap

public ParameterMap(int initialCapacity)
Construct a new, empty map with the specified initial capacity and default load factor.

Parameters:
initialCapacity - The initial capacity of this map

ParameterMap

public ParameterMap(int initialCapacity,
                    float loadFactor)
Construct a new, empty map with the specified initial capacity and load factor.

Parameters:
initialCapacity - The initial capacity of this map
loadFactor - The load factor of this map

ParameterMap

public ParameterMap(java.util.Map<K,V> map)
Construct a new map with the same mappings as the given map.

Parameters:
map - Map whose contents are duplicated in the new map
Method Detail

isLocked

public boolean isLocked()
Return the locked state of this parameter map.


setLocked

public void setLocked(boolean locked)
Set the locked state of this parameter map.

Parameters:
locked - The new locked state

clear

public void clear()
Remove all mappings from this map.

Specified by:
clear in interface java.util.Map<K,V>
Overrides:
clear in class java.util.LinkedHashMap<K,V>
Throws:
java.lang.IllegalStateException - if this map is currently locked

put

public V put(K key,
             V value)
Associate the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.

Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class java.util.HashMap<K,V>
Parameters:
key - Key with which the specified value is to be associated
value - Value to be associated with the specified key
Returns:
The previous value associated with the specified key, or null if there was no mapping for key
Throws:
java.lang.IllegalStateException - if this map is currently locked

putAll

public void putAll(java.util.Map<? extends K,? extends V> map)
Copy all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified Map.

Specified by:
putAll in interface java.util.Map<K,V>
Overrides:
putAll in class java.util.HashMap<K,V>
Parameters:
map - Mappings to be stored into this map
Throws:
java.lang.IllegalStateException - if this map is currently locked

remove

public V remove(java.lang.Object key)
Remove the mapping for this key from the map if present.

Specified by:
remove in interface java.util.Map<K,V>
Overrides:
remove in class java.util.HashMap<K,V>
Parameters:
key - Key whose mapping is to be removed from the map
Returns:
The previous value associated with the specified key, or null if there was no mapping for that key
Throws:
java.lang.IllegalStateException - if this map is currently locked

Apache Tomcat 6.0.53

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.