Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public abstract Class CacheValue<V>

extends Object
Class Inheritance
Known Direct Subclasses
com.ibm.icu.impl.CacheValue.NullValue, com.ibm.icu.impl.CacheValue.StrongValue, com.ibm.icu.impl.CacheValue.SoftValue
Type Parameters
<V>
Cache instance value type
Imports
java.lang.ref.Reference, .SoftReference, com.ibm.icu.util.ICUException

Value type for cache items: Holds a value either via a direct reference or via a Reference, depending on the current "strength" when getInstance() was called.

The value is conceptually immutable. If it is held via a direct reference, then it is actually immutable.

A Reference may be cleared (garbage-collected), after which get() returns null. It can then be reset via resetIfAbsent(). The new value should be the same as, or equivalent to, the old value.

Null values are supported. They can be distinguished from cleared values via isNull().

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
public static enum
CacheValue.Strength

"Strength" of holding a value in CacheValue instances.

private static class

Field Summary

Modifier and TypeField and Description
private static final CacheValue<V>
private static volatile CacheValue.Strength

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean
futureInstancesWillBeStrong()

Returns true if the "strength" is set to STRONG.

public abstract V
get()

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.

public static <V> CacheValue<V>
getInstance(V value)

Returns a CacheValue instance that holds the value.

public boolean

Returns:

true if this object represents a null value.
isNull
()

Distinguishes a null value from a Reference value that has been cleared.

public abstract V

Returns:

The old or new value.
resetIfCleared
(V
Replacement value, for when the current Reference has been cleared.
value
)

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned.

public static void
setStrength(CacheValue.Strength strength)

Changes the "strength" of value references for subsequent getInstance() calls.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NULL_VALUEback to summary
private static final CacheValue<V> NULL_VALUE
Annotations
@SuppressWarnings:rawtypes
strengthback to summary
private static volatile CacheValue.Strength strength

Constructor Detail

CacheValueback to summary
public CacheValue()

Method Detail

futureInstancesWillBeStrongback to summary
public static boolean futureInstancesWillBeStrong()

Returns true if the "strength" is set to STRONG.

getback to summary
public abstract V get()

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.

getInstanceback to summary
public static <V> CacheValue<V> getInstance(V value)

Returns a CacheValue instance that holds the value. It holds it directly if the value is null or if the current "strength" is STRONG. Otherwise, it holds it via a Reference.

Annotations
@SuppressWarnings:unchecked
isNullback to summary
public boolean isNull()

Distinguishes a null value from a Reference value that has been cleared.

Returns:boolean

true if this object represents a null value.

resetIfClearedback to summary
public abstract V resetIfCleared(V value)

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned. The old and new values should be the same or equivalent.

Otherwise the old value is returned.

Parameters
value:V

Replacement value, for when the current Reference has been cleared.

Returns:V

The old or new value.

setStrengthback to summary
public static void setStrength(CacheValue.Strength strength)

Changes the "strength" of value references for subsequent getInstance() calls.

com.ibm.icu.impl back to summary

private final Class CacheValue.NullValue<V>

extends CacheValue<V>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public V
get()

Implements abstract com.ibm.icu.impl.CacheValue.get.

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.
public boolean
isNull()

Overrides com.ibm.icu.impl.CacheValue.isNull.

Distinguishes a null value from a Reference value that has been cleared.
public V
resetIfCleared(V
Replacement value, for when the current Reference has been cleared.
value
)

Implements abstract com.ibm.icu.impl.CacheValue.resetIfCleared.

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned.
Inherited from com.ibm.icu.impl.CacheValue:
futureInstancesWillBeStronggetInstancesetStrength

Constructor Detail

NullValueback to summary
private NullValue()

Method Detail

getback to summary
public V get()

Implements abstract com.ibm.icu.impl.CacheValue.get.

Doc from com.ibm.icu.impl.CacheValue.get.

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.

Annotations
@Override
isNullback to summary
public boolean isNull()

Overrides com.ibm.icu.impl.CacheValue.isNull.

Doc from com.ibm.icu.impl.CacheValue.isNull.

Distinguishes a null value from a Reference value that has been cleared.

Returns:boolean

true if this object represents a null value.

Annotations
@Override
resetIfClearedback to summary
public V resetIfCleared(V value)

Implements abstract com.ibm.icu.impl.CacheValue.resetIfCleared.

Doc from com.ibm.icu.impl.CacheValue.resetIfCleared.

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned. The old and new values should be the same or equivalent.

Otherwise the old value is returned.

Parameters
value:V

Replacement value, for when the current Reference has been cleared.

Returns:V

The old or new value.

Annotations
@Override
com.ibm.icu.impl back to summary

private final Class CacheValue.SoftValue<V>

extends CacheValue<V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private volatile Reference<V>

Constructor Summary

AccessConstructor and Description
pack-priv
SoftValue(V value)

Method Summary

Modifier and TypeMethod and Description
public V
get()

Implements abstract com.ibm.icu.impl.CacheValue.get.

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.
public synchronized V
resetIfCleared(V
Replacement value, for when the current Reference has been cleared.
value
)

Implements abstract com.ibm.icu.impl.CacheValue.resetIfCleared.

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned.
Inherited from com.ibm.icu.impl.CacheValue:
futureInstancesWillBeStronggetInstanceisNullsetStrength

Field Detail

refback to summary
private volatile Reference<V> ref

Constructor Detail

SoftValueback to summary
pack-priv SoftValue(V value)

Method Detail

getback to summary
public V get()

Implements abstract com.ibm.icu.impl.CacheValue.get.

Doc from com.ibm.icu.impl.CacheValue.get.

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.

Annotations
@Override
resetIfClearedback to summary
public synchronized V resetIfCleared(V value)

Implements abstract com.ibm.icu.impl.CacheValue.resetIfCleared.

Doc from com.ibm.icu.impl.CacheValue.resetIfCleared.

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned. The old and new values should be the same or equivalent.

Otherwise the old value is returned.

Parameters
value:V

Replacement value, for when the current Reference has been cleared.

Returns:V

The old or new value.

Annotations
@Override
com.ibm.icu.impl back to summary

public final Enum CacheValue.Strength

extends Enum<CacheValue.Strength>
Class Inheritance

"Strength" of holding a value in CacheValue instances. The default strength is SOFT.

Field Summary

Modifier and TypeField and Description
public static final CacheValue.Strength
SOFT

Subsequent getInstance()-created objects will hold SoftReferences to their values.

public static final CacheValue.Strength
STRONG

Subsequent getInstance()-created objects will hold direct references to their values.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CacheValue.Strength
public static CacheValue.Strength[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

SOFTback to summary
public static final CacheValue.Strength SOFT

Subsequent getInstance()-created objects will hold SoftReferences to their values.

STRONGback to summary
public static final CacheValue.Strength STRONG

Subsequent getInstance()-created objects will hold direct references to their values.

Constructor Detail

Strengthback to summary
private Strength()

Method Detail

valueOfback to summary
public static CacheValue.Strength valueOf(String name)
valuesback to summary
public static CacheValue.Strength[] values()
com.ibm.icu.impl back to summary

private final Class CacheValue.StrongValue<V>

extends CacheValue<V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private V

Constructor Summary

AccessConstructor and Description
pack-priv
StrongValue(V value)

Method Summary

Modifier and TypeMethod and Description
public V
get()

Implements abstract com.ibm.icu.impl.CacheValue.get.

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.
public V
resetIfCleared(V
Replacement value, for when the current Reference has been cleared.
value
)

Implements abstract com.ibm.icu.impl.CacheValue.resetIfCleared.

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned.
Inherited from com.ibm.icu.impl.CacheValue:
futureInstancesWillBeStronggetInstanceisNullsetStrength

Field Detail

valueback to summary
private V value

Constructor Detail

StrongValueback to summary
pack-priv StrongValue(V value)

Method Detail

getback to summary
public V get()

Implements abstract com.ibm.icu.impl.CacheValue.get.

Doc from com.ibm.icu.impl.CacheValue.get.

Returns the value (which can be null), or null if it was held in a Reference and has been cleared.

Annotations
@Override
resetIfClearedback to summary
public V resetIfCleared(V value)

Implements abstract com.ibm.icu.impl.CacheValue.resetIfCleared.

Doc from com.ibm.icu.impl.CacheValue.resetIfCleared.

If the value was held via a Reference which has been cleared, then it is replaced with a new Reference to the new value, and the new value is returned. The old and new values should be the same or equivalent.

Otherwise the old value is returned.

Parameters
value:V

Replacement value, for when the current Reference has been cleared.

Returns:V

The old or new value.

Annotations
@Override