FileDocCategorySizeDatePackage
ParameterMap.javaAPI DocApache Tomcat 6.0.145709Fri Jul 20 04:20:30 BST 2007org.apache.catalina.util

ParameterMap

public final class ParameterMap extends HashMap
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
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

Fields Summary
private boolean
locked
The current lock state of this parameter map.
private static final StringManager
sm
The string manager for this package.
Constructors Summary
public ParameterMap()
Construct a new, empty map with the default initial capacity and load factor.


        super();

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

param
initialCapacity The initial capacity of this map


        super(initialCapacity);

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

param
initialCapacity The initial capacity of this map
param
loadFactor The load factor of this map


        super(initialCapacity, loadFactor);

    
public ParameterMap(Map map)
Construct a new map with the same mappings as the given map.

param
map Map whose contents are dupliated in the new map


        super(map);

    
Methods Summary
public voidclear()
Remove all mappings from this map.

exception
IllegalStateException if this map is currently locked



    // --------------------------------------------------------- Public Methods



                       
       

        if (locked)
            throw new IllegalStateException
                (sm.getString("parameterMap.locked"));
        super.clear();

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



                 
       

        return (this.locked);

    
public java.lang.Objectput(java.lang.Object key, java.lang.Object 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.

param
key Key with which the specified value is to be associated
param
value Value to be associated with the specified key
return
The previous value associated with the specified key, or null if there was no mapping for key
exception
IllegalStateException if this map is currently locked


        if (locked)
            throw new IllegalStateException
                (sm.getString("parameterMap.locked"));
        return (super.put(key, value));

    
public voidputAll(java.util.Map 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.

param
map Mappings to be stored into this map
exception
IllegalStateException if this map is currently locked


        if (locked)
            throw new IllegalStateException
                (sm.getString("parameterMap.locked"));
        super.putAll(map);

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

param
key Key whose mapping is to be removed from the map
return
The previous value associated with the specified key, or null if there was no mapping for that key
exception
IllegalStateException if this map is currently locked


        if (locked)
            throw new IllegalStateException
                (sm.getString("parameterMap.locked"));
        return (super.remove(key));

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

param
locked The new locked state


        this.locked = locked;