JBoss Common Classes 2.2.17.GA

org.jboss.util.collection
Class ReferenceValueMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.jboss.util.collection.ReferenceValueMap<K,V>
Type Parameters:
K - the key type
V - the value type
All Implemented Interfaces:
Map<K,V>
Direct Known Subclasses:
ReferenceValueHashMap, ReferenceValueTreeMap

public abstract class ReferenceValueMap<K,V>
extends AbstractMap<K,V>

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

Author:
Bill Burke, Adrian Brock, Ales Justin

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
protected ReferenceValueMap()
           
protected ReferenceValueMap(Comparator<K> comparator)
           
protected ReferenceValueMap(int initialCapacity)
           
protected ReferenceValueMap(int initialCapacity, float loadFactor)
           
protected ReferenceValueMap(Map<K,V> t)
           
protected ReferenceValueMap(SortedMap<K,ValueRef<K,V>> sorted)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
protected abstract  ValueRef<K,V> create(K key, V value, ReferenceQueue<V> q)
          Create new value ref instance.
protected abstract  Map<K,ValueRef<K,V>> createMap()
          Create map.
protected abstract  Map<K,ValueRef<K,V>> createMap(Comparator<K> comparator)
          Create map.
protected abstract  Map<K,ValueRef<K,V>> createMap(int initialCapacity)
          Create map.
protected abstract  Map<K,ValueRef<K,V>> createMap(int initialCapacity, float loadFactor)
          Create map.
protected abstract  Map<K,ValueRef<K,V>> createMap(SortedMap<K,ValueRef<K,V>> map)
          Create map.
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 V put(K key, V value)
           
 V remove(Object key)
           
 int size()
           
 String toString()
           
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReferenceValueMap

protected ReferenceValueMap()

ReferenceValueMap

protected ReferenceValueMap(int initialCapacity)

ReferenceValueMap

protected ReferenceValueMap(int initialCapacity,
                            float loadFactor)

ReferenceValueMap

protected ReferenceValueMap(Map<K,V> t)

ReferenceValueMap

protected ReferenceValueMap(Comparator<K> comparator)

ReferenceValueMap

protected ReferenceValueMap(SortedMap<K,ValueRef<K,V>> sorted)
Method Detail

createMap

protected abstract Map<K,ValueRef<K,V>> createMap()
Create map.

Returns:
new map instance

createMap

protected abstract Map<K,ValueRef<K,V>> createMap(int initialCapacity)
Create map.

Parameters:
initialCapacity - the initial capacity
Returns:
new map instance

createMap

protected abstract Map<K,ValueRef<K,V>> createMap(int initialCapacity,
                                                  float loadFactor)
Create map.

Parameters:
initialCapacity - the initial capacity
loadFactor - the load factor
Returns:
new map instance

createMap

protected abstract Map<K,ValueRef<K,V>> createMap(Comparator<K> comparator)
Create map.

Parameters:
comparator - the comparator
Returns:
new map instance

createMap

protected abstract Map<K,ValueRef<K,V>> createMap(SortedMap<K,ValueRef<K,V>> map)
Create map.

Parameters:
map - the sorted map
Returns:
new map instance

size

public int size()
Specified by:
size in interface Map<K,V>
Overrides:
size in class AbstractMap<K,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class AbstractMap<K,V>

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Overrides:
get in class AbstractMap<K,V>

put

public V put(K key,
             V value)
Specified by:
put in interface Map<K,V>
Overrides:
put in class AbstractMap<K,V>

remove

public V remove(Object key)
Specified by:
remove in interface Map<K,V>
Overrides:
remove in class AbstractMap<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Specified by:
entrySet in class AbstractMap<K,V>

clear

public void clear()
Specified by:
clear in interface Map<K,V>
Overrides:
clear in class AbstractMap<K,V>

create

protected abstract ValueRef<K,V> create(K key,
                                        V value,
                                        ReferenceQueue<V> q)
Create new value ref instance.

Parameters:
key - the key
value - the value
q - the ref queue
Returns:
new value ref instance

toString

public String toString()
Overrides:
toString in class AbstractMap<K,V>

JBoss Common Classes 2.2.17.GA

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