|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The GenericStorage
represents a generic storage
which enforce a simple policy based on a maximum capacity.
It contains methods to add, remove and get resources from the
storage. You may also inspect the content of the storage using
the iterator and check its capacity and usage.
Field Summary |
Fields inherited from interface anthill.storage.Storage |
DOC_STORAGE, PHR_STORAGE, URL_STORAGE |
Method Summary | |
void |
addResource(Object key,
Resource resource)
Adds a resource to the storage and associates it to the specified key. |
boolean |
containsResource(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(Object key)
Returns the resource associated with the specified key. |
Iterator |
iterator()
Returns the complete set of resources stored in this storage object using an iterator. |
void |
removeResource(Object key)
Removes the resource associated with the specified key from the storage. |
Methods inherited from interface anthill.util.Clearable |
clear |
Method Detail |
public Resource getResource(Object key)
key
- whose associated resource to retreive.
public boolean containsResource(Object key)
key
is contained in
the storage, false otherwise.
key
- the key to be searched
key
is contained in
the storagepublic void addResource(Object key, Resource resource) throws CapacityException
CapacityException
is thrown
containing information about the remaining capacity. Method
getContentLength()
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.
key
- the key identifying the resourceresource
- the resource to be added
CapacityException
- raised if the given resource object
exceeds the total available capacity for this storage.public void removeResource(Object key)
key
- the identifier of the resource to be removedpublic Iterator iterator()
public long getCapacity()
public long getRemainingCapacity()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |