org.apache.openjpa.lib.util
Class ReferenceHashMap

java.lang.Object
  extended by org.apache.commons.collections.map.ReferenceMap
      extended by org.apache.openjpa.lib.util.ReferenceHashMap
All Implemented Interfaces:
Map, ReferenceMap, SizedMap

public class ReferenceHashMap
extends ReferenceMap
implements ReferenceMap, SizedMap

Map in which the key, value, or both may be weak/soft references.

Since:
0.4.0
Author:
Abe White

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from interface org.apache.openjpa.lib.util.ReferenceMap
HARD, SOFT, WEAK
 
Constructor Summary
ReferenceHashMap(int keyType, int valueType)
           
ReferenceHashMap(int keyType, int valueType, int capacity, float loadFactor)
           
 
Method Summary
protected  void addMapping(int hashIndex, int hashCode, Object key, Object value)
           
protected  HashEntry createEntry(HashEntry next, int hashCode, Object key, Object value)
           
protected  void doReadObject(ObjectInputStream in)
           
protected  void doWriteObject(ObjectOutputStream out)
           
 int getMaxSize()
          The maximum number of entries, or Integer.MAX_VALUE for no limit.
 boolean isFull()
          Whether the map is full.
 void keyExpired(Object value)
          Overridable callback for when a key reference expires.
 void overflowRemoved(Object key, Object value)
          Overridable callback for when an overflow entry is automatically removed.
protected  void purge(Reference ref)
           
 void removeExpired()
          Purge stale entries.
 void setMaxSize(int maxSize)
          The maximum number of entries, or Integer.MAX_VALUE for no limit.
 void valueExpired(Object key)
          Overridable callback for when a value reference expires.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

ReferenceHashMap

public ReferenceHashMap(int keyType,
                        int valueType)

ReferenceHashMap

public ReferenceHashMap(int keyType,
                        int valueType,
                        int capacity,
                        float loadFactor)
Method Detail

getMaxSize

public int getMaxSize()
Description copied from interface: SizedMap
The maximum number of entries, or Integer.MAX_VALUE for no limit.

Specified by:
getMaxSize in interface SizedMap

setMaxSize

public void setMaxSize(int maxSize)
Description copied from interface: SizedMap
The maximum number of entries, or Integer.MAX_VALUE for no limit.

Specified by:
setMaxSize in interface SizedMap

isFull

public boolean isFull()
Description copied from interface: SizedMap
Whether the map is full.

Specified by:
isFull in interface SizedMap

overflowRemoved

public void overflowRemoved(Object key,
                            Object value)
Description copied from interface: SizedMap
Overridable callback for when an overflow entry is automatically removed.

Specified by:
overflowRemoved in interface SizedMap

valueExpired

public void valueExpired(Object key)
Description copied from interface: ReferenceMap
Overridable callback for when a value reference expires.

Specified by:
valueExpired in interface ReferenceMap
Parameters:
key - the key for the expired value

keyExpired

public void keyExpired(Object value)
Description copied from interface: ReferenceMap
Overridable callback for when a key reference expires.

Specified by:
keyExpired in interface ReferenceMap
Parameters:
value - the value for the expired key

removeExpired

public void removeExpired()
Description copied from interface: ReferenceMap
Purge stale entries.

Specified by:
removeExpired in interface ReferenceMap

addMapping

protected void addMapping(int hashIndex,
                          int hashCode,
                          Object key,
                          Object value)

createEntry

protected HashEntry createEntry(HashEntry next,
                                int hashCode,
                                Object key,
                                Object value)

purge

protected void purge(Reference ref)

doWriteObject

protected void doWriteObject(ObjectOutputStream out)
                      throws IOException
Throws:
IOException

doReadObject

protected void doReadObject(ObjectInputStream in)
                     throws ClassNotFoundException,
                            IOException
Throws:
ClassNotFoundException
IOException


Copyright © 2006 Apache Software Foundation. All Rights Reserved.