Package com.ibm.icu.impl
Class ICUResourceBundleReader.ResourceCache
- java.lang.Object
-
- com.ibm.icu.impl.ICUResourceBundleReader.ResourceCache
-
- Enclosing class:
- ICUResourceBundleReader
private static final class ICUResourceBundleReader.ResourceCache extends java.lang.Object
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 Classes Modifier and Type Class Description private static class
ICUResourceBundleReader.ResourceCache.Level
-
Field Summary
Fields Modifier and Type Field Description private int[]
keys
private int
length
private int
levelBitsList
Number of bits in each level, each stored in a nibble.private int
maxOffsetBits
private static int
NEXT_BITS
private static int
ROOT_BITS
private ICUResourceBundleReader.ResourceCache.Level
rootLevel
private static int
SIMPLE_LENGTH
private java.lang.Object[]
values
-
Constructor Summary
Constructors Constructor Description ResourceCache(int maxOffset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
findSimple(int key)
(package private) java.lang.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) java.lang.Object
putIfAbsent(int res, java.lang.Object item, int size)
private static java.lang.Object
putIfCleared(java.lang.Object[] values, int index, java.lang.Object item, int size)
private static boolean
storeDirectly(int size)
-
-
-
Field Detail
-
SIMPLE_LENGTH
private static final int SIMPLE_LENGTH
- See Also:
- Constant Field Values
-
ROOT_BITS
private static final int ROOT_BITS
- See Also:
- Constant Field Values
-
NEXT_BITS
private static final int NEXT_BITS
- See Also:
- Constant Field Values
-
keys
private int[] keys
-
values
private java.lang.Object[] values
-
length
private int length
-
maxOffsetBits
private int maxOffsetBits
-
levelBitsList
private int levelBitsList
Number of bits in each level, each stored in a nibble.
-
rootLevel
private ICUResourceBundleReader.ResourceCache.Level rootLevel
-
-
Method Detail
-
storeDirectly
private static boolean storeDirectly(int size)
-
putIfCleared
private static final java.lang.Object putIfCleared(java.lang.Object[] values, int index, java.lang.Object item, int size)
-
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
java.lang.Object get(int res)
-
putIfAbsent
java.lang.Object putIfAbsent(int res, java.lang.Object item, int size)
-
-