SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

serp.util
Class ReferenceMap

java.lang.Object
  |
  +--serp.util.ReferenceMap
All Implemented Interfaces:
Map

public class ReferenceMap
extends Object
implements Map

A map whose keys and values can be stored as weak or soft references. This class is similar to the ReferenceMap type found in the Jakart Commons Collections project, but is more flexible because it allows null values, it can inherit the strategy of any other map type, and it allows any key or value to have any reference type (see put(Object,int,Object,int).

Expired values are removed from the map before any mutator methods; removing before accessor methods can lead to ConcurrentModificationExceptions. Thus, the following methods may produce results which include key/value pairs that have expired:

By default, all methods are delegated to the internal map provided at construction. Thus, the ordering, etc of the given map will be preserved; however, the hashing algorithm cannot be duplicated. A special case is made for the IdentityMap's hashing, which is supported. Performance is similar to that of the internal map instance.


Inner classes inherited from class java.util.Map
Map.Entry
 
Field Summary
static int HARD
          Hard reference marker.
static int SOFT
          Soft reference marker.
static int WEAK
          Weak reference marker.
 
Constructor Summary
ReferenceMap()
          Equivalent to ReferenceMap (ReferenceMap.HARD, ReferenceMap.HARD).
ReferenceMap(int defaultKeyType, int defaultValueType)
          Equivalent to ReferenceMap (defaultKeyType, defaultValueType, new HashMap ()).
ReferenceMap(int defaultKeyType, int defaultValueType, Map map)
          Construct a ReferenceMap with the given interal default key and value reference types, and have it use the given map for storage.
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set entrySet()
           
 boolean equals(Object other)
           
 Object get(Object key)
           
 boolean isEmpty()
           
 Set keySet()
           
 Object put(Object key, int keyType, Object value, int valueType)
          Set the given key, while specifying the key and value reference types.
 Object put(Object key, Object value)
           
 void putAll(Map map)
           
 Object remove(Object key)
           
 int size()
           
 String toString()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
hashCode
 

Field Detail

HARD

public static final int HARD
Hard reference marker.

SOFT

public static final int SOFT
Soft reference marker.

WEAK

public static final int WEAK
Weak reference marker.
Constructor Detail

ReferenceMap

public ReferenceMap()
Equivalent to ReferenceMap (ReferenceMap.HARD, ReferenceMap.HARD).

ReferenceMap

public ReferenceMap(int defaultKeyType,
                    int defaultValueType)
Equivalent to ReferenceMap (defaultKeyType, defaultValueType, new HashMap ()).

ReferenceMap

public ReferenceMap(int defaultKeyType,
                    int defaultValueType,
                    Map map)
Construct a ReferenceMap with the given interal default key and value reference types, and have it use the given map for storage. The map will be cleared. It should not be accessed in any way after being given to this constructor; this map will 'inherit' its behavior, however. For example, if the given map is a LinkedHashMap, the values method of this map will return values in insertion order.
Method Detail

clear

public void clear()
Specified by:
clear in interface Map

containsKey

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

containsValue

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

entrySet

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

equals

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

get

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

keySet

public Set keySet()
Specified by:
keySet in interface Map

put

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

put

public Object put(Object key,
                  int keyType,
                  Object value,
                  int valueType)
Set the given key, while specifying the key and value reference types.

putAll

public void putAll(Map map)
Specified by:
putAll in interface Map

remove

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

size

public int size()
Specified by:
size in interface Map

values

public Collection values()
Specified by:
values in interface Map

toString

public String toString()
Overrides:
toString in class Object

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

Copyright 2001,2002,2003 SolarMetric, Inc. All Rights Reserved.