Adempiere 3.5.2a

org.compiere.util
Class CCache<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<K,V>
          extended by org.compiere.util.CCache<K,V>
Type Parameters:
K - Key
V - Value
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>, CacheInterface
Direct Known Subclasses:
NaturalAccountMap

public class CCache<K,V>
extends HashMap<K,V>
implements CacheInterface

Adempiere Cache.

Version:
$Id: CCache.java,v 1.2 2006/07/30 00:54:35 jjanke Exp $
Author:
Jorg Janke
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
CCache(String name, int initialCapacity)
          Adempiere Cache - expires after 2 hours
CCache(String name, int initialCapacity, int expireMinutes)
          Adempiere Cache
 
Method Summary
 void addVetoableChangeListener(VetoableChangeListener listener)
          Add Vetoable Change Listener
 void clear()
          Clear cache and calculate new expiry time
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
           
 V get(Object key)
           
 int getExpireMinutes()
          Get Expire Minutes
 String getName()
          Get (table) Name
 boolean isEmpty()
           
 boolean isReset()
          Cache was reset
 Set<K> keySet()
           
 V put(K key, V value)
          Put value
 void putAll(Map<? extends K,? extends V> m)
          Put All
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Remove Vetoable Change Listener
 int reset()
          Reset Cache
 void setExpireMinutes(int expireMinutes)
          Set Expire Minutes and start it
 void setUsed()
          Resets the Reset flag
 int size()
          Get Size of Cache
 int sizeNoExpire()
          Get Size w/o Expire
 String toString()
          String Representation
 Collection<V> values()
           
 
Methods inherited from class java.util.HashMap
clone, remove
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

CCache

public CCache(String name,
              int initialCapacity)
Adempiere Cache - expires after 2 hours

Parameters:
name - (table) name of the cache
initialCapacity - initial capacity

CCache

public CCache(String name,
              int initialCapacity,
              int expireMinutes)
Adempiere Cache

Parameters:
name - (table) name of the cache
initialCapacity - initial capacity
expireMinutes - expire after minutes (0=no expire)
Method Detail

getName

public String getName()
Get (table) Name

Returns:
name

setExpireMinutes

public void setExpireMinutes(int expireMinutes)
Set Expire Minutes and start it

Parameters:
expireMinutes - minutes or 0

getExpireMinutes

public int getExpireMinutes()
Get Expire Minutes

Returns:
expire minutes

isReset

public boolean isReset()
Cache was reset

Returns:
true if reset

setUsed

public void setUsed()
Resets the Reset flag


reset

public int reset()
Reset Cache

Specified by:
reset in interface CacheInterface
Returns:
number of items cleared
See Also:
CacheInterface.reset()

toString

public String toString()
String Representation

Overrides:
toString in class AbstractMap<K,V>
Returns:
info

clear

public void clear()
Clear cache and calculate new expiry time

Specified by:
clear in interface Map<K,V>
Overrides:
clear in class HashMap<K,V>
See Also:
Map.clear()

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in class HashMap<K,V>
See Also:
Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in class HashMap<K,V>
See Also:
Map.containsValue(java.lang.Object)

entrySet

public Set<Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface Map<K,V>
Overrides:
entrySet in class HashMap<K,V>
See Also:
Map.entrySet()

get

public V get(Object key)
Specified by:
get in interface Map<K,V>
Overrides:
get in class HashMap<K,V>
See Also:
Map.get(java.lang.Object)

put

public V put(K key,
             V value)
Put value

Specified by:
put in interface Map<K,V>
Overrides:
put in class HashMap<K,V>
Parameters:
key - key
value - value
Returns:
previous value

putAll

public void putAll(Map<? extends K,? extends V> m)
Put All

Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in class HashMap<K,V>
Parameters:
m - map

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class HashMap<K,V>
See Also:
Map.isEmpty()

keySet

public Set<K> keySet()
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in class HashMap<K,V>
See Also:
Map.keySet()

size

public int size()
Description copied from interface: CacheInterface
Get Size of Cache

Specified by:
size in interface Map<K,V>
Specified by:
size in interface CacheInterface
Overrides:
size in class HashMap<K,V>
Returns:
number of items
See Also:
Map.size()

sizeNoExpire

public int sizeNoExpire()
Get Size w/o Expire

Returns:
size
See Also:
Map.size()

values

public Collection<V> values()
Specified by:
values in interface Map<K,V>
Overrides:
values in class HashMap<K,V>
See Also:
Map.values()

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Add Vetoable Change Listener

Parameters:
listener - listner

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Remove Vetoable Change Listener

Parameters:
listener - listener

Adempiere 3.5.2a

Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.