org.mycore.frontend.indexbrowser.lucene
Class MCRIndexBrowserCache

java.lang.Object
  extended by org.mycore.frontend.indexbrowser.lucene.MCRIndexBrowserCache

public class MCRIndexBrowserCache
extends Object

Caches index browser entries in a hash table. Each object type gets an entry in the table. The value of an entry is a MCRCache. This cache again creates new entries for different search and modes. So the cache key is: object index # search # mode

Author:
Matthias Eichner

Field Summary
protected static Logger LOGGER
           
 
Constructor Summary
MCRIndexBrowserCache()
           
 
Method Summary
protected static MCRCache addIndexCacheToHashtable(String index)
          Adds a new MCRCache to the hash table.
static void addToCache(MCRIndexBrowserIncomingData browseData, String index, List<MCRIndexBrowserEntry> listToCache)
          Add a new list of index browser entries to the cache.
static void deleteIndexCacheFromHashtable(String objectType)
          Deletes a whole MCRCache from the hash table.
protected static String getCacheKey(String index, MCRIndexBrowserIncomingData browseData)
          Returns the cache key from the incoming browser data.
static List<MCRIndexBrowserEntry> getFromCache(String index, MCRIndexBrowserIncomingData browseData)
          Returns the cached index browser list.
protected static MCRCache getIndexCache(String index)
          Returns the MCRCache from the hash table by the given index name.
static boolean isCached(String index, MCRIndexBrowserIncomingData browseData)
          Checks if a hash table entry with the specified index exists.
static boolean isInHashtable(String key)
          Checks if the entry exists in the hash table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static Logger LOGGER
Constructor Detail

MCRIndexBrowserCache

public MCRIndexBrowserCache()
Method Detail

addToCache

public static void addToCache(MCRIndexBrowserIncomingData browseData,
                              String index,
                              List<MCRIndexBrowserEntry> listToCache)
Add a new list of index browser entries to the cache.

Parameters:
listToCache - a list to cache

addIndexCacheToHashtable

protected static MCRCache addIndexCacheToHashtable(String index)
Adds a new MCRCache to the hash table.

Parameters:
index - the key of the entry.

deleteIndexCacheFromHashtable

public static void deleteIndexCacheFromHashtable(String objectType)
Deletes a whole MCRCache from the hash table.

Parameters:
objectType - the object type which has to be removed

getFromCache

public static List<MCRIndexBrowserEntry> getFromCache(String index,
                                                      MCRIndexBrowserIncomingData browseData)
Returns the cached index browser list.

Returns:
the cached list.

getIndexCache

protected static MCRCache getIndexCache(String index)
Returns the MCRCache from the hash table by the given index name.

Parameters:
index - the index name of the specific index browser
Returns:
a MCRCache from the hash table

getCacheKey

protected static String getCacheKey(String index,
                                    MCRIndexBrowserIncomingData browseData)
Returns the cache key from the incoming browser data.

Returns:
the cache key in the form of index # search # mode

isCached

public static boolean isCached(String index,
                               MCRIndexBrowserIncomingData browseData)
Checks if a hash table entry with the specified index exists. If true, the method checks if the specified key exists in the MCRCache.

Returns:
true if an entry in the hash table and in the MCRCache exists, otherwise false

isInHashtable

public static boolean isInHashtable(String key)
Checks if the entry exists in the hash table.

Parameters:
key - the key which will be checked
Returns:
true if the entry was found, otherwise false