anl.aida.client
Class Cache

java.lang.Object
  extended by anl.aida.client.Cache

public class Cache
extends java.lang.Object

Encapsulates a Cache.


Field Summary
private  java.io.File cacheDirectory
           
private  java.util.Map<anl.aida.util.DateRange,CacheElement> items
           
private  Keywords keywords
           
private  java.io.File luceneLocation
           
private  anl.aida.util.DateRangeProducer ranger
           
private  int totalDocs
           
 
Constructor Summary
Cache(java.io.File luceneLocation, java.io.File cacheDirectory, anl.aida.util.DateRangeProducer ranger)
          Creates a cache.
 
Method Summary
 void add(java.lang.String keywordSet, java.lang.String keyword)
          Adds the specified keyword to the specified keyword set in this cache.
 void addCacheElement(CacheElement item)
          Adds the specified CacheElement to this cache.
 java.lang.Iterable<CacheElement> elements()
          Gets an iteratble over all the elements in this cache.
 java.io.File getCacheDirectory()
          Gets the directory where the cache resides.
 CacheElement getElement(anl.aida.util.DateRange range)
          Gets the element that covers the specified date range.
 CacheElement getElement(int id)
          Gets the element by its numeric id.
 Keywords getKeywords()
          Gets the keywords associated with this cache.
 java.io.File getLuceneLocation()
          Gets the location of this cache's lucene index.
 anl.aida.util.DateRangeProducer getRanger()
          Gets the DateRangeProducer that covers the date range interval of this Cache.
 int getTotalDocs()
          Gets the total number of docs in this cache.
 void setKeywords(Keywords keywords)
          Sets the keywords for this cache.
 int size()
          Gets the number of cache elements in this cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

luceneLocation

private java.io.File luceneLocation

cacheDirectory

private java.io.File cacheDirectory

items

private java.util.Map<anl.aida.util.DateRange,CacheElement> items

ranger

private anl.aida.util.DateRangeProducer ranger

totalDocs

private int totalDocs

keywords

private Keywords keywords
Constructor Detail

Cache

public Cache(java.io.File luceneLocation,
             java.io.File cacheDirectory,
             anl.aida.util.DateRangeProducer ranger)
Creates a cache.

Parameters:
luceneLocation - the location of the lucene index from which the cache was created
ranger - a DateRangeProducer that can produce the date ranges of the individual cache elements
Method Detail

getCacheDirectory

public java.io.File getCacheDirectory()
Gets the directory where the cache resides.

Returns:
the directory where the cache resides.

getLuceneLocation

public java.io.File getLuceneLocation()
Gets the location of this cache's lucene index.

Returns:
the location of this cache's lucene index.

getTotalDocs

public int getTotalDocs()
Gets the total number of docs in this cache.

Returns:
the total number of docs in this cache.

addCacheElement

public void addCacheElement(CacheElement item)
Adds the specified CacheElement to this cache.

Parameters:
item - the element to add

size

public int size()
Gets the number of cache elements in this cache.

Returns:
the number of cache elements in this cache.

getElement

public CacheElement getElement(int id)
Gets the element by its numeric id.

Parameters:
id - the id of the element to get
Returns:
the element by its numeric id.

getElement

public CacheElement getElement(anl.aida.util.DateRange range)
Gets the element that covers the specified date range.

Parameters:
range - the range of the element to get
Returns:
the element that covers the specified date range.

elements

public java.lang.Iterable<CacheElement> elements()
Gets an iteratble over all the elements in this cache.

Returns:
an iteratble over all the elements in this cache.

getRanger

public anl.aida.util.DateRangeProducer getRanger()
Gets the DateRangeProducer that covers the date range interval of this Cache.

Returns:
the DateRangeProducer that covers the date range interval of this Cache.

add

public void add(java.lang.String keywordSet,
                java.lang.String keyword)
Adds the specified keyword to the specified keyword set in this cache.

Parameters:
keywordSet - the set to add the keyword to
keyword - the keyword to add

getKeywords

public Keywords getKeywords()
Gets the keywords associated with this cache.

Returns:
the keywords associated with this cache.

setKeywords

public void setKeywords(Keywords keywords)
Sets the keywords for this cache.

Parameters:
keywords - the new keywords for this cache