org.geotools.util
Class WeakValueHashMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byorg.geotools.util.WeakValueHashMap
All Implemented Interfaces:
java.util.Map

public class WeakValueHashMap
extends java.util.AbstractMap

A hashtable-based Map implementation with weak values. An entry in a will automatically be removed when its value is no longer in ordinary use. This class is similar to the standard WeakHashMap class provided is J2SE, except that weak references are hold on values instead of keys.

The class is thread-safe.

Since:
2.0
Version:
$Id: WeakValueHashMap.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
WeakHashMap, WeakHashSet

Constructor Summary
WeakValueHashMap()
          Construct a .
 
Method Summary
 void clear()
          Removes all of the elements from this map.
 boolean containsKey(java.lang.Object key)
          Returns if this map contains a mapping for the specified key.
 boolean containsValue(java.lang.Object value)
          Returns if this map maps one or more keys to this value.
 java.util.Set entrySet()
          Returns a set view of the mappings contained in this map.
 java.lang.Object get(java.lang.Object key)
          Returns the value to which this map maps the specified key.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates the specified value with the specified key in this map.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from this map if present.
 int size()
          Returns the number of key-value mappings in this map.
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakValueHashMap

public WeakValueHashMap()
Construct a .

Method Detail

size

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


containsValue

public boolean containsValue(java.lang.Object value)
Returns if this map maps one or more keys to this value.

Parameters:
value - value whose presence in this map is to be tested.
Returns:
if this map maps one or more keys to this value.

containsKey

public boolean containsKey(java.lang.Object key)
Returns if this map contains a mapping for the specified key.

Parameters:
key - key whose presence in this map is to be tested.
Returns:
if this map contains a mapping for the specified key.
Throws:
java.lang.NullPointerException - If key is .

get

public java.lang.Object get(java.lang.Object key)
Returns the value to which this map maps the specified key. Returns if the map contains no mapping for this key.

Parameters:
key - Key whose associated value is to be returned.
Returns:
The value to which this map maps the specified key.
Throws:
java.lang.NullPointerException - if the key is .

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Associates the specified value with the specified key in this map. The value is associated using a WeakReference.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or if there was no mapping for key.
Throws:
java.lang.NullPointerException - if the key or the value is .

remove

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

Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or if there was no entry for key.

clear

public void clear()
Removes all of the elements from this map.


entrySet

public java.util.Set entrySet()
Returns a set view of the mappings contained in this map. Each element in this set is a Map.Entry. The current implementation thrown UnsupportedOperationException.

Returns:
a set view of the mappings contained in this map.


Copyright © GeoTools. All Rights Reserved.