edu.mit.jwi
Interface ICachingDictionary.IItemCache

All Superinterfaces:
IClosable, IHasLifecycle
All Known Implementing Classes:
CachingDictionary.ItemCache
Enclosing interface:
ICachingDictionary

public static interface ICachingDictionary.IItemCache
extends IHasLifecycle

The cache used by a caching dictionary.

Since:
JWI 2.2.0
Version:
2.4.0
Author:
Mark A. Finlayson

Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.mit.jwi.data.IHasLifecycle
IHasLifecycle.LifecycleState, IHasLifecycle.ObjectClosedException, IHasLifecycle.ObjectOpenException
 
Method Summary
 void cacheItem(IItem<?> item)
          Caches the specified item, if this cache is enabled.
 void cacheSenseEntry(ISenseEntry entry)
          Caches the specified entry.
 void cacheWordByKey(IWord word)
          Caches the specified word, indexed by its sense key.
 void clear()
          Removes all entries from the cache.
 int getMaximumCapacity()
          Returns the maximum capacity of this cache.
 boolean isEnabled()
          Returns true if this cache is enabled; false otherwise.
<T extends IItem<D>,D extends IItemID<T>>
T
retrieveItem(D id)
          Retrieves the item identified by the specified id.
 ISenseEntry retrieveSenseEntry(ISenseKey key)
          Retrieves the sense entry identified by the specified sense key.
 IWord retrieveWord(ISenseKey key)
          Retrieves the word identified by the specified sense key.
 void setEnabled(boolean isEnabled)
          Enables (true) or disables (false) caching.
 void setMaximumCapacity(int capacity)
          Sets the maximum capacity of the cache
 int size()
          Returns the number of items in the cache.
 
Methods inherited from interface edu.mit.jwi.data.IHasLifecycle
isOpen, open
 
Methods inherited from interface edu.mit.jwi.data.IClosable
close
 

Method Detail

isEnabled

boolean isEnabled()
Returns true if this cache is enabled; false otherwise. If a cache is enabled, it will cache an item passed to its cache methods.

Returns:
true if this cache is enabled; false otherwise
Since:
JWI 2.2.0

setEnabled

void setEnabled(boolean isEnabled)
Enables (true) or disables (false) caching.

Parameters:
isEnabled - if true, caching is enabled; if false, caching is disabled.
Since:
JWI 2.2.0

setMaximumCapacity

void setMaximumCapacity(int capacity)
Sets the maximum capacity of the cache

Parameters:
capacity - the maximum capacity
Since:
JWI 2.2.0

getMaximumCapacity

int getMaximumCapacity()
Returns the maximum capacity of this cache.

Returns:
the maximum capacity of this cache.
Since:
JWI 2.2.0

size

int size()
Returns the number of items in the cache.

Returns:
the number of items in the cache.
Since:
JWI 2.2.0

cacheItem

void cacheItem(IItem<?> item)
Caches the specified item, if this cache is enabled. Otherwise does nothing.

Parameters:
item - the item to be cached; may not be null
Throws:
java.lang.NullPointerException - if the specified item is null
Since:
JWI 2.2.0

cacheWordByKey

void cacheWordByKey(IWord word)
Caches the specified word, indexed by its sense key.

Parameters:
word - the word to be cached; may not be null
Throws:
java.lang.NullPointerException - if the specified word is null
Since:
JWI 2.2.0

cacheSenseEntry

void cacheSenseEntry(ISenseEntry entry)
Caches the specified entry.

Parameters:
entry - the entry to be cached; may not be null
Throws:
java.lang.NullPointerException - if the specified entry is null
Since:
JWI 2.2.0

retrieveItem

<T extends IItem<D>,D extends IItemID<T>> T retrieveItem(D id)
Retrieves the item identified by the specified id.

Type Parameters:
T - the type of the item
D - the type of the item id
Parameters:
id - the id for the requested item
Returns:
the item for the specified id, or null if not present in the cache
Throws:
java.lang.NullPointerException - if the specified id is null
Since:
JWI 2.2.0

retrieveWord

IWord retrieveWord(ISenseKey key)
Retrieves the word identified by the specified sense key.

Parameters:
key - the sense key for the requested word
Returns:
the word for the specified key, or null if not present in the cache
Throws:
java.lang.NullPointerException - if the specified key is null
Since:
JWI 2.2.0

retrieveSenseEntry

ISenseEntry retrieveSenseEntry(ISenseKey key)
Retrieves the sense entry identified by the specified sense key.

Parameters:
key - the sense key for the requested sense entry
Returns:
the sense entry for the specified key, or null if not present in the cache
Throws:
java.lang.NullPointerException - if the specified key is null
Since:
JWI 2.2.0

clear

void clear()
Removes all entries from the cache.

Since:
JWI 2.2.0


Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.