All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.util.JCCache

java.lang.Object
   |
   +----jclass.util.JCCache

public class JCCache
extends Object
JCCache class implements a lightweight cache that works on any Object-based (key, value) pair. To use this cache, the key class must implement the following methods:


Constructor Index

 o JCCache(int, int)
This is the constructor for JCCache.

Method Index

 o addToCache(Object, Object)
This adds a key or item pair to the cache.
 o getFromCache(Object)
This retrieves the item associated with the key from the cache.
 o toString()
This converts the cache contents to a large string.

Constructors

 o JCCache
  public JCCache(int bins,
                 int binsize)
This is the constructor for JCCache. Internally, the cache is made up of a nuber of buckets of a certain size. As data is added to the cache, it is added to a bucket based on its hash value.

Parameters:
bins - the number of buckets int the cache
binsize - the length of each bucket

Methods

 o addToCache
  public final void addToCache(Object key,
                               Object item)
This adds a key or item pair to the cache. If the item is already in the cache, the value is updated.

Parameters:
key - the key object for the cached item
item - the item to add to the cache
 o getFromCache
  public final Object getFromCache(Object key)
This retrieves the item associated with the key from the cache. If no item is found, getFromCache() returns null.

Parameters:
key - the key object for the cached item
Returns:
cached item
 o toString
  public final String toString()
This converts the cache contents to a large string. This is useful only for debugging purposes.

Returns:
string for printing
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index