|
|||||||||||
| 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.CompositeCache
This class models a Cache that is based on subcaches. All the Caches are used. There is an order of priority between the sub caches so that the results coming from one have preeminence over the next ones. The highest priority cache is used when objects are registered in this cache.
| Constructor Summary | |
CompositeCache(Cache mainSubCache)
Creates a new instance of CompositeCache |
|
CompositeCache(Cache[] subCaches)
Creates a new instance of CompositeCache. |
|
| Method Summary | |
void |
addSubCache(Cache cache)
Adds a cache at the end of the list of Cache. |
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 |
insertSubCache(Cache cache,
int position)
Adds a cache at the given position of the list of Cache. |
void |
registerAllObjects(java.util.Map m)
This is a convenience method. |
void |
registerObject(java.lang.Object key,
java.lang.Object value)
Registers an object in the cache using the given key to refer to it. |
void |
removeSubCache(Cache cache)
Removes a cache from the list. |
void |
removeSubCache(int position)
Removes a cache from the list. |
void |
unregisterObject(java.lang.Object key)
Removes the object associated with the given key 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 |
public CompositeCache(Cache mainSubCache)
throws java.lang.IllegalArgumentException
mainSubCache - the main cache in the composite. It is the cache that is
primarily used to register objects.
java.lang.IllegalArgumentException - if the mainSubCache is null.
public CompositeCache(Cache[] subCaches)
throws java.lang.IllegalArgumentException
subCaches - the subcaches to use. The first cache in the array will be
considered the main cache.
java.lang.IllegalArgumentException - if the subCaches is null or empty.| Method Detail |
public void clear()
clear in interface Cacheclear in class BaseCachepublic java.lang.Object[] getAllObjects()
getAllObjects in interface CachegetAllObjects in class BaseCachepublic java.lang.Object[] getAllObjects(java.lang.Class type)
getAllObjects in interface CachegetAllObjects in class BaseCachetype - the type to give to the object in the result array.
public java.util.Map getMap()
public java.lang.Object getObject(java.lang.Object key)
getObject in interface CachegetObject in class BaseCachekey - the key used to register the searched object.
public int getSize()
getSize in interface CachegetSize in class BaseCache
public void registerAllObjects(java.util.Map m)
throws CacheFullException
m - the map that contains the objects (and keys) to use.
CacheFullException - when the Cache would exceed its maximum size and no room can
be made.
public void registerObject(java.lang.Object key,
java.lang.Object value)
throws CacheFullException
registerObject in interface CacheregisterObject in class BaseCachekey - the key to use to retrieve the object.value - the object to store in the Cache.
CacheFullException - when the Cache would exceed its maximum size and no room can
be made.public void unregisterObject(java.lang.Object key)
unregisterObject in interface CacheunregisterObject in class BaseCachekey - the key associated to the object to be removed.public void addSubCache(Cache cache)
cache - the cache to be added. Nothing happens it it is null or if it
already is in the CompositeCache.
public void insertSubCache(Cache cache,
int position)
cache - the cache to be added. Nothing happens it it is null or if it
already is in the CompositeCache.position - in the CompositeCache. If the position is lesser than -1 or
greater than the number of caches in the composite, the cache
is added at the last position.public void removeSubCache(Cache cache)
cache - the cache to be removed. Nothing happens it it is null or if
it already is in the CompositeCache.public void removeSubCache(int position)
position - the position of the cache to remove.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||