ants.jxtagnutant
Class UrlStorage

java.lang.Object
  |
  +--anthill.storage.impl.LRUKeyStorage
        |
        +--anthill.storage.impl.LRUQueryStorage
              |
              +--ants.jxtagnutant.UrlStorage
All Implemented Interfaces:
Clearable, GenericStorage, QueryStorage, ResourceManager, Storage

public class UrlStorage
extends LRUQueryStorage
implements QueryStorage

Implementation of an Least Recently Used (LRU) based URL storage.

Version:
$Revision: 1.3 $
Author:
Hein Meling

Field Summary
 
Fields inherited from class anthill.storage.impl.LRUQueryStorage
PAR_CONTROLLERNAME
 
Fields inherited from class anthill.storage.impl.LRUKeyStorage
factory, list, name, PAR_STORAGENAME, storage
 
Fields inherited from interface anthill.storage.Storage
DOC_STORAGE, PHR_STORAGE, URL_STORAGE
 
Constructor Summary
UrlStorage(Factory factory, String name)
           
 
Method Summary
 void addResource(Object resourceKey, Resource urlResource)
          Adds a resource to the storage and associates it to the specified key.
 Resource[] getResources(Object query)
          Return the resource associated with the specified query.
 
Methods inherited from class anthill.storage.impl.LRUQueryStorage
clear
 
Methods inherited from class anthill.storage.impl.LRUKeyStorage
containsResource, getCapacity, getRemainingCapacity, getResource, iterator, removeResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface anthill.storage.GenericStorage
containsResource, getCapacity, getRemainingCapacity, getResource, iterator, removeResource
 
Methods inherited from interface anthill.util.Clearable
clear
 

Constructor Detail

UrlStorage

public UrlStorage(Factory factory,
                  String name)
Method Detail

addResource

public void addResource(Object resourceKey,
                        Resource urlResource)
                 throws CapacityException
Adds a resource to the storage and associates it to the specified key. If the remaining capacity of the storage is not sufficient to store the resource, a 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. This is a specialized implementation that will add URLs pointing to a file with the same resourceKey to a URL resource set before adding that URL set to the storage.

Specified by:
addResource in interface GenericStorage
Overrides:
addResource in class LRUKeyStorage
Parameters:
resourceKey - the key identifying the URL resource
urlResource - the URL resource to be added
Throws:
CapacityException - raised if the given resource object exceeds the total available capacity for this storage.

getResources

public Resource[] getResources(Object query)
Description copied from interface: QueryStorage
Return the resource associated with the specified query.

Specified by:
getResources in interface QueryStorage
Overrides:
getResources in class LRUQueryStorage
Parameters:
query - whose associated resource to retreive.
Returns:
resources found in the storage with which the specified query matched.