java.lang.Object | +--com.ibm.commerce.order.calculation.Cache
An abstract class for implementing LRU cache classes.
Field Summary | |
---|---|
static java.lang.String |
COPYRIGHT The IBM copyright notice fields. |
static int |
DEFAULT_MAX_SIZE The default maximum cache size. |
Constructor Summary | |
---|---|
Cache() Constructor for Cache, with a maximum size of DEFAULT_MAX_SIZE . | |
Cache(int anMaxSize) Constructor for Cache. |
Method Summary | |
---|---|
void |
clear() Clears the cache. |
java.lang.Object |
get(java.lang.Object aKey) Returns the value which the key is mapped to. |
protected
int |
getSize(java.lang.Object aValue) Returns the size of a value. |
protected
abstract java.lang.Object |
miss(java.lang.Object aKey) Returns the value a key is mapped to. |
java.lang.Object |
remove(java.lang.Object aKey) Removes the value which the key is mapped to. |
void |
setMaxSize(int anMaxSize) Sets the maximum size of the cache. |
void |
setSize(int anMaxSize) Deprecated. renamed to setMaxSize(int) . |
java.lang.String |
toString() Returns the string representation of the cache for diagnostic purposes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait,
wait, wait |
Field Detail |
---|
public static final java.lang.String COPYRIGHT
public static final int DEFAULT_MAX_SIZE
Constructor Detail |
---|
public Cache()
DEFAULT_MAX_SIZE
.
public Cache(int anMaxSize)
anMaxSize
- the maximum size of the cache.Method Detail |
---|
public void clear()
public java.lang.Object remove(java.lang.Object aKey) throws ECException
aKey
- the key.ECException
public java.lang.Object get(java.lang.Object aKey) throws ECException
aKey
- the key.ECException
protected int getSize(java.lang.Object aValue)
get(Object)
and should be overridden by the implementing
class.
aValue
- the value.protected abstract java.lang.Object miss(java.lang.Object aKey) throws ECException
get(Object)
when the mapping is not found in the cache and
should be overridden by the implementing class.
aKey
- the key.ECException
public void setMaxSize(int anMaxSize)
anMaxSize
- the maximum size of the cache.public void setSize(int anMaxSize)
setMaxSize(int)
.
anMaxSize
- the maximum size of the cache.public java.lang.String toString()
toString
in class java.lang.Object