Package com.ibm.icu.impl
Class ICUResourceBundleReader.ResourceCache
java.lang.Object
com.ibm.icu.impl.ICUResourceBundleReader.ResourceCache
- Enclosing class:
ICUResourceBundleReader
Cache of some of one resource bundle's resources.
Avoids creating multiple Java objects for the same resource items,
including multiple copies of their contents.
Mutable objects must not be cached and then returned to the caller because the cache must not be writable via the returned reference.
Resources are mapped by their resource integers. Empty resources with offset 0 cannot be mapped. Integers need not and should not be cached. Multiple .res items may share resource offsets (genrb eliminates some duplicates).
This cache uses int[] and Object[] arrays to minimize object creation and avoid auto-boxing.
Large resource objects are usually stored in SoftReferences.
For few resources, a small table is used with binary search. When more resources are cached, then the data structure changes to be faster but also use more memory.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
private int
private int
Number of bits in each level, each stored in a nibble.private int
private static final int
private static final int
private static final int
private Object[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
findSimple
(int key) (package private) Object
get
(int res) private int
makeKey
(int res) Turns a resource integer (with unused bits in the middle) into a key with fewer bits (at most keyBits).(package private) Object
putIfAbsent
(int res, Object item, int size) private static final Object
putIfCleared
(Object[] values, int index, Object item, int size) private static boolean
storeDirectly
(int size)
-
Field Details
-
SIMPLE_LENGTH
private static final int SIMPLE_LENGTH- See Also:
-
ROOT_BITS
private static final int ROOT_BITS- See Also:
-
NEXT_BITS
private static final int NEXT_BITS- See Also:
-
keys
private int[] keys -
values
-
length
private int length -
maxOffsetBits
private int maxOffsetBits -
levelBitsList
private int levelBitsListNumber of bits in each level, each stored in a nibble. -
rootLevel
-
-
Constructor Details
-
ResourceCache
ResourceCache(int maxOffset)
-
-
Method Details
-
storeDirectly
private static boolean storeDirectly(int size) -
putIfCleared
-
makeKey
private int makeKey(int res) Turns a resource integer (with unused bits in the middle) into a key with fewer bits (at most keyBits). -
findSimple
private int findSimple(int key) -
get
-
putIfAbsent
-