com.thoughtworks.xstream.core.util
Class WeakCache

java.lang.Object
  extended by java.util.AbstractMap
      extended by com.thoughtworks.xstream.core.util.WeakCache
All Implemented Interfaces:
Map

public class WeakCache
extends AbstractMap

A HashMap implementation with weak references values and by default for the key. WHen the value is garbage collected, the key will also vanish from the map.

Since:
1.4
Author:
Jörg Schaible

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
WeakCache()
          Construct a WeakCache with weak keys.
WeakCache(Map map)
          Construct a WeakCache.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
protected  Reference createReference(Object value)
           
 Set entrySet()
           
 boolean equals(Object o)
           
 Object get(Object key)
           
 int hashCode()
           
 Set keySet()
           
 Object put(Object key, Object value)
           
 Object remove(Object key)
           
 int size()
           
 String toString()
           
 Collection values()
           
 
Methods inherited from class java.util.AbstractMap
clone, isEmpty, putAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WeakCache

public WeakCache()
Construct a WeakCache with weak keys.

Parameters:
map - the map to use
Since:
1.4

WeakCache

public WeakCache(Map map)
Construct a WeakCache.

Parameters:
map - the map to use
Since:
1.4
Method Detail

get

public Object get(Object key)
Specified by:
get in interface Map
Overrides:
get in class AbstractMap

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
Overrides:
put in class AbstractMap

remove

public Object remove(Object key)
Specified by:
remove in interface Map
Overrides:
remove in class AbstractMap

createReference

protected Reference createReference(Object value)

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map
Overrides:
containsValue in class AbstractMap

size

public int size()
Specified by:
size in interface Map
Overrides:
size in class AbstractMap

values

public Collection values()
Specified by:
values in interface Map
Overrides:
values in class AbstractMap

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Specified by:
entrySet in class AbstractMap

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
Overrides:
containsKey in class AbstractMap

clear

public void clear()
Specified by:
clear in interface Map
Overrides:
clear in class AbstractMap

keySet

public Set keySet()
Specified by:
keySet in interface Map
Overrides:
keySet in class AbstractMap

equals

public boolean equals(Object o)
Specified by:
equals in interface Map
Overrides:
equals in class AbstractMap

hashCode

public int hashCode()
Specified by:
hashCode in interface Map
Overrides:
hashCode in class AbstractMap

toString

public String toString()
Overrides:
toString in class AbstractMap


Copyright © 2012. All Rights Reserved.