Class GenericCache
java.lang.Object
org.apache.oro.util.GenericCache
- All Implemented Interfaces:
Serializable, Cache
- Direct Known Subclasses:
CacheLRU
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
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default capacity to be used by the GenericCache subclasses provided with this package. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddElement(Object key, Object value) Adds an element to the cache.final intcapacity()Returns the maximum number of elements that can be cached at one time.getElement(Object key) Gets an element from the cache.final booleanisFull()Checks if the cache is full.keys()Gets the cache objects names.final intsize()Returns the number of elements in the cache, not to be confused with thecapacity()which returns the number of elements that can be held in the cache at one time.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYThe default capacity to be used by the GenericCache subclasses provided with this package. Its value is 20.- See Also:
-
-
Method Details
-
addElement
Description copied from interface:CacheAdds an element to the cache.- Specified by:
addElementin interfaceCache- Parameters:
key- Keyvalue- Value
-
getElement
Description copied from interface:CacheGets an element from the cache.- Specified by:
getElementin interfaceCache- Parameters:
key- Key- Returns:
- Element value
-
keys
-
size
public final int size()Returns the number of elements in the cache, not to be confused with thecapacity()which returns the number of elements that can be held in the cache at one time. -
capacity
-
isFull
public final boolean isFull()Checks if the cache is full.- Returns:
trueif the cache is full,falseotherwise
-