JBoss ClassPool Parent POM 1.0.0.GA

org.jboss.classpool.scoped
Class SoftValueHashMap

java.lang.Object
  extended by java.util.AbstractMap<String,javassist.CtClass>
      extended by org.jboss.classpool.scoped.SoftValueHashMap
All Implemented Interfaces:
Map<String,javassist.CtClass>

public class SoftValueHashMap
extends AbstractMap<String,javassist.CtClass>
implements Map<String,javassist.CtClass>

This Map will remove entries when the value in the map has been cleaned from garbage collection

Version:
$Revision: 104485 $
Author:
Bill Burke

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
SoftValueHashMap()
          Constructs a new, empty WeakHashMap with the default initial capacity and the default load factor, which is 0.75.
SoftValueHashMap(int initialCapacity)
          Constructs a new, empty WeakHashMap with the given initial capacity and the default load factor, which is 0.75.
SoftValueHashMap(int initialCapacity, float loadFactor)
          Constructs a new, empty WeakHashMap with the given initial capacity and the given load factor.
SoftValueHashMap(Map<String,javassist.CtClass> t)
          Constructs a new WeakHashMap with the same mappings as the specified Map.
 
Method Summary
 void clear()
          Removes all mappings from this map.
 boolean containsKey(Object key)
          Returns true if this map contains a mapping for the specified key.
 Set<Map.Entry<String,javassist.CtClass>> entrySet()
          Returns a set of the mappings contained in this hash table.
 javassist.CtClass get(Object key)
          Returns the value to which this map maps the specified key.
 boolean isEmpty()
          Returns true if this map contains no key-value mappings.
 javassist.CtClass put(String key, javassist.CtClass value)
          Updates this map so that the given key maps to the given value.
 org.jboss.classpool.scoped.SoftValueHashMap.SoftValueRef remove(String key)
          Removes the mapping for the given 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, containsValue, equals, hashCode, keySet, putAll, remove, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
containsValue, equals, hashCode, keySet, putAll, remove, values
 

Constructor Detail

SoftValueHashMap

public SoftValueHashMap(int initialCapacity,
                        float loadFactor)
Constructs a new, empty WeakHashMap with the given initial capacity and the given load factor.

Parameters:
initialCapacity - the initial capacity of the WeakHashMap
loadFactor - the load factor of the WeakHashMap
Throws:
IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive

SoftValueHashMap

public SoftValueHashMap(int initialCapacity)
Constructs a new, empty WeakHashMap with the given initial capacity and the default load factor, which is 0.75.

Parameters:
initialCapacity - the initial capacity of the WeakHashMap
Throws:
IllegalArgumentException - if the initial capacity is less than zero

SoftValueHashMap

public SoftValueHashMap()
Constructs a new, empty WeakHashMap with the default initial capacity and the default load factor, which is 0.75.


SoftValueHashMap

public SoftValueHashMap(Map<String,javassist.CtClass> t)
Constructs a new WeakHashMap with the same mappings as the specified Map. The WeakHashMap is created with an initial capacity of twice the number of mappings in the specified map or 11 (whichever is greater), and a default load factor, which is 0.75.

Parameters:
t - the map whose mappings are to be placed in this map.
Method Detail

entrySet

public Set<Map.Entry<String,javassist.CtClass>> entrySet()
Returns a set of the mappings contained in this hash table.

Specified by:
entrySet in interface Map<String,javassist.CtClass>
Specified by:
entrySet in class AbstractMap<String,javassist.CtClass>

size

public int size()
Returns the number of key-value mappings in this map. Note: In contrast with most implementations of the Map interface, the time required by this operation is linear in the size of the map.

Specified by:
size in interface Map<String,javassist.CtClass>
Overrides:
size in class AbstractMap<String,javassist.CtClass>

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.

Specified by:
isEmpty in interface Map<String,javassist.CtClass>
Overrides:
isEmpty in class AbstractMap<String,javassist.CtClass>

containsKey

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

Specified by:
containsKey in interface Map<String,javassist.CtClass>
Overrides:
containsKey in class AbstractMap<String,javassist.CtClass>
Parameters:
key - the key whose presence in this map is to be tested

get

public javassist.CtClass get(Object key)
Returns the value to which this map maps the specified key. If this map does not contain a value for this key, then return null.

Specified by:
get in interface Map<String,javassist.CtClass>
Overrides:
get in class AbstractMap<String,javassist.CtClass>
Parameters:
key - the key whose associated value, if any, is to be returned

put

public javassist.CtClass put(String key,
                             javassist.CtClass value)
Updates this map so that the given key maps to the given value. If the map previously contained a mapping for key then that mapping is replaced and the previous value is returned.

Specified by:
put in interface Map<String,javassist.CtClass>
Overrides:
put in class AbstractMap<String,javassist.CtClass>
Parameters:
key - the key that is to be mapped to the given value
value - the value to which the given key is to be mapped
Returns:
the previous value to which this key was mapped, or null if if there was no mapping for the key

remove

public org.jboss.classpool.scoped.SoftValueHashMap.SoftValueRef remove(String key)
Removes the mapping for the given key from this map, if present.

Parameters:
key - the key whose mapping is to be removed
Returns:
the value to which this key was mapped, or null if there is no mapping for the key.

clear

public void clear()
Removes all mappings from this map.

Specified by:
clear in interface Map<String,javassist.CtClass>
Overrides:
clear in class AbstractMap<String,javassist.CtClass>

JBoss ClassPool Parent POM 1.0.0.GA

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.