|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jcreme.caches.BaseCache
org.jcreme.caches.HashCache
A Cache object using no particular policy. This implementation is based on a Hashtable.
Constructor Summary | |
|
HashCache()
Creates new HashCache |
protected |
HashCache(CachePolicy policy)
Creates new HashCache |
protected |
HashCache(int minSize,
int maxSize,
CachePolicy policy)
Creates new HashCache |
Method Summary | |
void |
clear()
Removes all the objects from the Cache, leaving it empty. |
java.lang.Object[] |
getAllObjects()
This method gives access to the full content of the cache. |
java.lang.Object[] |
getAllObjects(java.lang.Class type)
This method gives the same result as the getAllObjects method but the objects in the result array are types with the parameter type. |
java.util.Map |
getMap()
This method enables to access to the cache contents. |
java.lang.Object |
getObject(java.lang.Object key)
Gives access to an object registered in the cache. |
int |
getSize()
This methods gives the current size of the cache. |
void |
registerAllObjects(java.util.Map m)
This is a convenience method. |
void |
registerObject(java.lang.Object key,
java.lang.Object value)
This method adds an object in the cache. |
void |
unregisterObject(java.lang.Object key)
This method removes an object from the cache. |
Methods inherited from class org.jcreme.caches.BaseCache |
addCacheListener, buildEvent, fireElementAdded, fireElementRemoved, getCacheListeners, getMaxSize, getMinSize, getReplacementPolicy, removeCacheListener, setMaxSize, setReplacementPolicy |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected HashCache(int minSize, int maxSize, CachePolicy policy)
minSize
- the initial size of the Cache.maxSize
- the maximum number of objects contained by the cache.policy
- the policy to use in this cache. It is not implemented in this
class.protected HashCache(CachePolicy policy)
policy
- the policy to use in this cache.public HashCache()
Method Detail |
public void registerObject(java.lang.Object key, java.lang.Object value) throws CacheFullException
registerObject
in interface Cache
registerObject
in class BaseCache
key
- the key that will be used to retrieve the object.value
- the object to store in the cache.
CacheFullException
- if the object could not be stored in the cache.public void unregisterObject(java.lang.Object key)
unregisterObject
in interface Cache
unregisterObject
in class BaseCache
key
- the key that was used to store the object in the cache.public void clear()
clear
in interface Cache
clear
in class BaseCache
public int getSize()
getSize
in interface Cache
getSize
in class BaseCache
public java.lang.Object getObject(java.lang.Object key)
getObject
in interface Cache
getObject
in class BaseCache
key
- the key used to register the searched object.
public java.lang.Object[] getAllObjects()
getAllObjects
in interface Cache
getAllObjects
in class BaseCache
public java.lang.Object[] getAllObjects(java.lang.Class type)
getAllObjects
in interface Cache
getAllObjects
in class BaseCache
type
- the type to give to the object in the result array.
public java.util.Map getMap()
public void registerAllObjects(java.util.Map m)
m
- the map that contains the objects (and keys) to use.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |