org.apache.commons.collections
Class SoftRefHashMap

java.lang.Object
  |
  +--org.apache.commons.collections.SoftRefHashMap
All Implemented Interfaces:
java.util.Map

Deprecated. This class is all kinds of wonky; use ReferenceMap instead.

public class SoftRefHashMap
extends java.lang.Object
implements java.util.Map

HashMap with SoftReference links to values which allows the values of the Map to be garbage collected by the JVM if it becomes low on memory. Derive from this class and override the factory method createReference() method to make a Map wrapped in other types of Reference.

A synchronized version can be obtained with: Collections.synchronizedMap( theMapToSynchronize )

WARNING the values() and entrySet() methods require optimisation like the standard HashMap implementations so that iteration over this Map is efficient.

Since:
1.0
Author:
James.Dodd, James Strachan
See Also:
Bug#9571

Constructor Summary
SoftRefHashMap()
          Deprecated.  
 
Method Summary
 void clear()
          Deprecated. Clears all mappings
 boolean containsKey(java.lang.Object key)
          Deprecated. Answers whether the argument is in the domain of the mappings
 boolean containsValue(java.lang.Object value)
          Deprecated. Answers whether the argument is a Referenced value
 java.util.Set entrySet()
          Deprecated. Returns a set view of the mappings in the wrapped map
 boolean equals(java.lang.Object object)
          Deprecated. Answers whether this map and the argument are 'the same'
 java.lang.Object get(java.lang.Object key)
          Deprecated. Retrieves the referent of the Referenced value
 int hashCode()
          Deprecated. Calculates the hash code for this map
 boolean isEmpty()
          Deprecated. Answers whether there are any mappings
 java.util.Set keySet()
          Deprecated. Returns the domain of the mappings
 void purge()
          Deprecated. Removes References that have had their referents garbage collected
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Deprecated. Adds a key-value mapping, wrapping the value in a Reference
 void putAll(java.util.Map map)
          Deprecated. Put all of the mappings in the argument into this wrapped map
 java.lang.Object remove(java.lang.Object key)
          Deprecated. Removes a mapping from this map
 int size()
          Deprecated. Returns the number of mappings in this map
 java.util.Collection values()
          Deprecated. Returns a collection of the Referenced values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftRefHashMap

public SoftRefHashMap()
Deprecated. 
Method Detail

purge

public void purge()
Deprecated. 
Removes References that have had their referents garbage collected


get

public java.lang.Object get(java.lang.Object key)
Deprecated. 
Retrieves the referent of the Referenced value

Specified by:
get in interface java.util.Map
Parameters:
key - The key with which to retrieve the value

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Deprecated. 
Adds a key-value mapping, wrapping the value in a Reference

Specified by:
put in interface java.util.Map

values

public java.util.Collection values()
Deprecated. 
Returns a collection of the Referenced values

Specified by:
values in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object key)
Deprecated. 
Answers whether the argument is in the domain of the mappings

Specified by:
containsKey in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Deprecated. 
Answers whether the argument is a Referenced value

Specified by:
containsValue in interface java.util.Map

putAll

public void putAll(java.util.Map map)
Deprecated. 
Put all of the mappings in the argument into this wrapped map

Specified by:
putAll in interface java.util.Map

entrySet

public java.util.Set entrySet()
Deprecated. 
Returns a set view of the mappings in the wrapped map

Specified by:
entrySet in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Deprecated. 
Removes a mapping from this map

Specified by:
remove in interface java.util.Map

clear

public void clear()
Deprecated. 
Clears all mappings

Specified by:
clear in interface java.util.Map

hashCode

public int hashCode()
Deprecated. 
Calculates the hash code for this map

Specified by:
hashCode in interface java.util.Map
Overrides:
hashCode in class java.lang.Object

keySet

public java.util.Set keySet()
Deprecated. 
Returns the domain of the mappings

Specified by:
keySet in interface java.util.Map

isEmpty

public boolean isEmpty()
Deprecated. 
Answers whether there are any mappings

Specified by:
isEmpty in interface java.util.Map

equals

public boolean equals(java.lang.Object object)
Deprecated. 
Answers whether this map and the argument are 'the same'

Specified by:
equals in interface java.util.Map
Overrides:
equals in class java.lang.Object

size

public int size()
Deprecated. 
Returns the number of mappings in this map

Specified by:
size in interface java.util.Map


Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.