org.tbee.cache.simple
Class LeastRecentlyUsedCache<K,V>

java.lang.Object
  extended by org.tbee.cache.simple.LeastRecentlyUsedCache<K,V>
All Implemented Interfaces:
Map<K,V>, Cache<K,V>

public class LeastRecentlyUsedCache<K,V>
extends Object
implements Cache<K,V>

This cache has a maximum number of items it remembers. They may be clean out by the garbage collecter. If the cache is full and a new items is added, the least recently used item is remove from the cache to make room for the new item.

Version:
$Revision: 1.4 $
Author:
$Author: tom $

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static char MODE_SOFT
           
static char MODE_STRONG
           
static char MODE_WEAK
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
LeastRecentlyUsedCache()
          This constructor uses a cache size specified in as a system property, or a default value (10) if the property is not present.
LeastRecentlyUsedCache(char pMode)
          This constructor uses a cache size specified in as a system property, or a default value (10) if the property is not present.
LeastRecentlyUsedCache(char pMode, int pSize)
           
LeastRecentlyUsedCache(int pSize)
           
 
Method Summary
 void addAssociation(Object association)
           
 void addCacheListener(CacheListener pCacheListener)
          A cache listener listens to both finalize and remove events
 void clear()
           
 Object clone()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 Vector getAssociations()
           
 String getName()
           
 boolean isEmpty()
           
 Set keySet()
           
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> t)
           
 V remove(Object key)
           
 void removeCacheListener(CacheListener pCacheListener)
           
 void removeValue(Object value)
           
 void setName(String pName)
           
 int size()
           
 String toString()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.tbee.cache.simple.Cache
addAssociation, getName, setName
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

MODE_STRONG

public static char MODE_STRONG

MODE_SOFT

public static char MODE_SOFT

MODE_WEAK

public static char MODE_WEAK
Constructor Detail

LeastRecentlyUsedCache

public LeastRecentlyUsedCache()
This constructor uses a cache size specified in as a system property, or a default value (10) if the property is not present.


LeastRecentlyUsedCache

public LeastRecentlyUsedCache(char pMode)
This constructor uses a cache size specified in as a system property, or a default value (10) if the property is not present.


LeastRecentlyUsedCache

public LeastRecentlyUsedCache(char pMode,
                              int pSize)

LeastRecentlyUsedCache

public LeastRecentlyUsedCache(int pSize)
Method Detail

addCacheListener

public void addCacheListener(CacheListener pCacheListener)
A cache listener listens to both finalize and remove events

Specified by:
addCacheListener in interface Cache<K,V>

removeCacheListener

public void removeCacheListener(CacheListener pCacheListener)
Specified by:
removeCacheListener in interface Cache<K,V>

clear

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

clone

public Object clone()
Overrides:
clone in class Object

containsKey

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

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V>

entrySet

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

get

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,V>

keySet

public Set keySet()
Specified by:
keySet in interface Map<K,V>

put

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

putAll

public void putAll(Map<? extends K,? extends V> t)
Specified by:
putAll in interface Map<K,V>

remove

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

removeValue

public void removeValue(Object value)
Specified by:
removeValue in interface Cache<K,V>

size

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

toString

public String toString()
Overrides:
toString in class Object

values

public Collection values()
Specified by:
values in interface Map<K,V>

addAssociation

public void addAssociation(Object association)

getAssociations

public Vector getAssociations()

getName

public String getName()

setName

public void setName(String pName)


Copyright © 2010 KnowledgePlaza. All Rights Reserved.