|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.storage.impl.LRUKeyStorage
Implementation of an LRU based key storage. This is a wrapper class for storing resources based on using a key to access the resources.
Field Summary | |
protected HashList |
list
HashList use to implement the LRU policy of the LRU key storage. |
protected GenericStorage |
storage
A generic storage. |
Fields inherited from interface anthill.storage.Storage |
DOC_STORAGE, PHR_STORAGE, URL_STORAGE |
Constructor Summary | |
LRUKeyStorage(Factory factory,
java.lang.String storageName)
|
Method Summary | |
void |
addResource(java.lang.Object key,
Resource resource)
Adds a resource to the storage and associates it to the specified key. |
void |
clear()
Restore the object to its initial state |
boolean |
containsResource(java.lang.Object key)
Returns true if the resource associated to key is contained in
the storage, false otherwise. |
long |
getCapacity()
Returns the initial capacity of this generic storage. |
long |
getRemainingCapacity()
Returns the remaining capacity of this generic storage. |
Resource |
getResource(java.lang.Object key)
Returns the resource associated with the specified key. |
java.util.Iterator |
iterator()
Returns the complete set of resources stored in this storage object using an iterator. |
void |
removeResource(java.lang.Object key)
Removes the resource associated with the specified key from the storage. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected GenericStorage storage
protected HashList list
Constructor Detail |
public LRUKeyStorage(Factory factory, java.lang.String storageName)
Method Detail |
public boolean containsResource(java.lang.Object key)
key
is contained in
the storage, false otherwise.containsResource
in interface GenericStorage
key
- the key to be searchedkey
is contained in
the storagepublic Resource getResource(java.lang.Object key)
getResource
in interface GenericStorage
key
- whose associated resource to retreive.public void addResource(java.lang.Object key, Resource resource) throws CapacityException
CapacityException
is thrown
containing information about the remaining capacity. Method
size()
may be invoked on the resource
to determine the amount of space required by the resource.
In order to be stored on persistent storage, resource must
implement the Serializable
interface.addResource
in interface GenericStorage
key
- the key identifying the resourceresource
- the resource to be addedCapacityException
- raised if the given resource object
exceeds the total available capacity for this storage.public void removeResource(java.lang.Object key)
removeResource
in interface GenericStorage
key
- the identifier of the resource to be removedpublic java.util.Iterator iterator()
iterator
in interface GenericStorage
public long getCapacity()
getCapacity
in interface GenericStorage
public long getRemainingCapacity()
getRemainingCapacity
in interface GenericStorage
public void clear()
clear
in interface Clearable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |