Top Description Constructors Methods
com.ibm.icu.impl

public abstract Class CacheBase<K, V, D>

extends Object
Class Inheritance
Known Direct Subclasses
com.ibm.icu.impl.SoftCache
Type Parameters
<K>
Cache lookup key type
<V>
Cache instance value type
<D>
Data type for creating a new instance value

Base class for cache implementations. To use, instantiate a subclass of a concrete implementation class, where the subclass implements the createInstance() method, and call get() with the key and the data. The get() call will use the data only if it needs to call createInstance(), otherwise the data is ignored.
Author
Markus Scherer, Mark Davis

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract V

Returns:

The requested instance
createInstance
(K
Cache lookup key for the requested instance
key
,
D
Data for the instance creation
data
)

Creates an instance for the key and data.

public abstract V

Returns:

The requested instance
getInstance
(K
Cache lookup key for the requested instance
key
,
D
Data for createInstance() if the instance is not already cached
data
)

Retrieves an instance from the cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CacheBaseback to summary
public CacheBase()

Method Detail

createInstanceback to summary
protected abstract V createInstance(K key, D data)

Creates an instance for the key and data. Must be overridden.

Parameters
key:K

Cache lookup key for the requested instance

data:D

Data for the instance creation

Returns:V

The requested instance

getInstanceback to summary
public abstract V getInstance(K key, D data)

Retrieves an instance from the cache. Calls createInstance(key, data) if the cache does not already contain an instance with this key. Ignores data if the cache already contains an instance with this key.

Parameters
key:K

Cache lookup key for the requested instance

data:D

Data for createInstance() if the instance is not already cached

Returns:V

The requested instance