Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.oro.util
Class GenericCache  view GenericCache download GenericCache.java

java.lang.Object
  extended byorg.apache.oro.util.GenericCache
All Implemented Interfaces:
Cache, java.io.Serializable
Direct Known Subclasses:
CacheFIFO, CacheFIFO2, CacheLRU, CacheRandom

public abstract class GenericCache
extends java.lang.Object
implements Cache, java.io.Serializable

This is the base class for all cache implementations provided in the org.apache.oro.util package. To derive a subclass from GenericCache only the ... methods need be overridden. Although 4 subclasses of GenericCache are provided with this package, users may not derive subclasses from this class. Rather, users should create their own implmentations of the Cache interface.

Since:
1.0
Version:
@version@

Field Summary
(package private)  GenericCacheEntry[] _cache
           
(package private)  int _numEntries
           
(package private)  java.util.HashMap _table
           
static int DEFAULT_CAPACITY
          The default capacity to be used by the GenericCache subclasses provided with this package.
 
Constructor Summary
(package private) GenericCache(int capacity)
          The primary constructor for GenericCache.
 
Method Summary
abstract  void addElement(java.lang.Object key, java.lang.Object value)
           
 int capacity()
          Returns the maximum number of elements that can be cached at one time.
 java.lang.Object getElement(java.lang.Object key)
           
 boolean isFull()
           
 java.util.Iterator keys()
           
 int size()
          Returns the number of elements in the cache, not to be confused with the capacity() 55 which returns the number of elements that can be held in the cache at one time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CAPACITY

public static final int DEFAULT_CAPACITY
The default capacity to be used by the GenericCache subclasses provided with this package. Its value is 20.

See Also:
Constant Field Values

_numEntries

int _numEntries

_cache

GenericCacheEntry[] _cache

_table

java.util.HashMap _table
Constructor Detail

GenericCache

GenericCache(int capacity)
The primary constructor for GenericCache. It has default access so it will only be used within the package. It initializes _table to a Hashtable of capacity equal to the capacity argument, _cache to an array of size equal to the capacity argument, and _numEntries to 0.

Method Detail

addElement

public abstract void addElement(java.lang.Object key,
                                java.lang.Object value)
Specified by:
addElement in interface Cache

getElement

public java.lang.Object getElement(java.lang.Object key)
Specified by:
getElement in interface Cache

keys

public final java.util.Iterator keys()

size

public final int size()
Returns the number of elements in the cache, not to be confused with the capacity() 55 which returns the number of elements that can be held in the cache at one time.

Specified by:
size in interface Cache

capacity

public final int capacity()
Returns the maximum number of elements that can be cached at one time.

Specified by:
capacity in interface Cache

isFull

public final boolean isFull()