com.cafesoft.core.util
Class NamespaceHashMap

java.lang.Object
  |
  +--com.cafesoft.core.util.NamespaceHashMap
All Implemented Interfaces:
NamespaceMap, Recyclable, Serializable

public class NamespaceHashMap
extends Object
implements NamespaceMap

A HashMap implementation of the NamespaceMap interface.

More specifically this class uses HashMaps as the underlying storage mechanisms. In addition, this particular class is thread-safe for writing values into the map. It employs the strategy of synchronizing only puts and removes.

Since:
5/14/02
See Also:
NamespaceMap, Serialized Form

Field Summary
 
Fields inherited from interface com.cafesoft.core.util.NamespaceMap
DEFAULT_NAMESPACE
 
Constructor Summary
NamespaceHashMap()
          Creates a NamespaceHashMap.
NamespaceHashMap(int initialCapacity)
          Creates a NamespaceHashMap with the specified initial capacity.
 
Method Summary
 Object get(String namespace, String name)
          Get a value from the NamespaceMap
 String[] getNames(String namespace)
          Get the names of all the values in the NamespaceMap
 String[] getNamespaces()
          Get all value namespaces.
 void put(String namespace, String name, Object value)
          Put an value into NamespaceMap Put an object into the NamespaceMap via a name string and namespace.
 void recycle()
          Recycle the resources of this object
 void remove(String namespace, String name)
          Remove a value from the NamespaceMap
 int size()
          Returns the number of key-value mappings in this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamespaceHashMap

public NamespaceHashMap()
Creates a NamespaceHashMap.


NamespaceHashMap

public NamespaceHashMap(int initialCapacity)
Creates a NamespaceHashMap with the specified initial capacity.

Parameters:
initialCapacity - the number of objects to be allocated upon creation
Method Detail

recycle

public void recycle()
Recycle the resources of this object

Specified by:
recycle in interface Recyclable

put

public void put(String namespace,
                String name,
                Object value)
Put an value into NamespaceMap

Put an object into the NamespaceMap via a name string and namespace.

Specified by:
put in interface NamespaceMap
Parameters:
namespace - a namespace used to distinguish a name (perhaps used by a particular application), from an identical name used in another context. If null, then use the "default" namespace.
name - the name of the value
value - the value to insert into the NamespaceMap
Throws:
IllegalArgumentException - thrown if the name is null

remove

public void remove(String namespace,
                   String name)
Remove a value from the NamespaceMap

Specified by:
remove in interface NamespaceMap
Parameters:
namespace - the namespace of the name/value pair
name - the name string of the value to remove
Throws:
IllegalArgumentException - thrown if the name is null

get

public Object get(String namespace,
                  String name)
Get a value from the NamespaceMap

Specified by:
get in interface NamespaceMap
Parameters:
namespace - the namespace of the name/value pair
name - the name string to get the value for
Returns:
The value from the NamespaceMap, null if the name doesn't exist.
Throws:
IllegalArgumentException - thrown if the name is null

getNamespaces

public String[] getNamespaces()
Get all value namespaces.

Specified by:
getNamespaces in interface NamespaceMap
Returns:
a String array of all namespaces used for values currently stored in the NamespaceMap including the "default" namepace.

getNames

public String[] getNames(String namespace)
Get the names of all the values in the NamespaceMap

Specified by:
getNames in interface NamespaceMap
Parameters:
namespace - the namespace of values to be retrieved. If null the default namespace is used
Returns:
a String array of all names in the NamespaceMap that contain values

size

public int size()
Returns the number of key-value mappings in this map.

Specified by:
size in interface NamespaceMap
Returns:
the number of key-value mappings in this map


Generated on 10:40:31 AM September 10, 2003, © 1996-2003 Cafésoft LLC. All rights reserved.