Package com.ibm.icu.impl
Class ICUResourceBundleReader
- java.lang.Object
-
- com.ibm.icu.impl.ICUResourceBundleReader
-
public final class ICUResourceBundleReader extends java.lang.Object
This class reads the *.res resource bundle format. For the file format documentation see ICU4C's source/common/uresdata.h file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ICUResourceBundleReader.Array
private static class
ICUResourceBundleReader.Array16
private static class
ICUResourceBundleReader.Array32
(package private) static class
ICUResourceBundleReader.Container
private static class
ICUResourceBundleReader.IsAcceptable
private static class
ICUResourceBundleReader.ReaderCache
private static class
ICUResourceBundleReader.ReaderCacheKey
(package private) static class
ICUResourceBundleReader.ReaderValue
private static class
ICUResourceBundleReader.ResourceCache
Cache of some of one resource bundle's resources.(package private) static class
ICUResourceBundleReader.Table
private static class
ICUResourceBundleReader.Table16
private static class
ICUResourceBundleReader.Table1632
private static class
ICUResourceBundleReader.Table32
-
Field Summary
Fields Modifier and Type Field Description private java.nio.CharBuffer
b16BitUnits
private java.nio.ByteBuffer
bytes
Buffer of all of the resource bundle bytes after the header.private static ICUResourceBundleReader.ReaderCache
CACHE
private static int
DATA_FORMAT
File format version that this class understands.private int
dataVersion
private static boolean
DEBUG
private static java.nio.CharBuffer
EMPTY_16_BIT_UNITS
private static ICUResourceBundleReader.Array
EMPTY_ARRAY
private static ICUResourceBundleReader.Table
EMPTY_TABLE
private static java.nio.ByteBuffer
emptyByteBuffer
private static byte[]
emptyBytes
private static char[]
emptyChars
private static int[]
emptyInts
private static java.lang.String
emptyString
private static java.lang.String
ICU_RESOURCE_SUFFIX
private static ICUResourceBundleReader.IsAcceptable
IS_ACCEPTABLE
private boolean
isPoolBundle
private byte[]
keyBytes
(package private) static int
LARGE_SIZE
Objects with more value bytes are stored in SoftReferences.private int
localKeyLimit
private boolean
noFallback
private static ICUResourceBundleReader
NULL_READER
private ICUResourceBundleReader
poolBundleReader
private int
poolCheckSum
private int
poolStringIndex16Limit
private int
poolStringIndexLimit
private static int[]
PUBLIC_TYPES
From C++ uresdata.c gPublicTypes[URES_LIMIT].private ICUResourceBundleReader.ResourceCache
resourceCache
private int
rootRes
private static int
URES_ATT_IS_POOL_BUNDLE
private static int
URES_ATT_NO_FALLBACK
private static int
URES_ATT_USES_POOL_BUNDLE
private static int
URES_INDEX_16BIT_TOP
[6] top of the 16-bit units (UTF-16 string v2 UChars, URES_TABLE16, URES_ARRAY16), rounded up (new in formatVersion 2.0, ICU 4.4)private static int
URES_INDEX_ATTRIBUTES
[5] attributes bit set, see URES_ATT_* (new in formatVersion 1.2) formatVersion>=3: bits 31..16 poolStringIndex16Limit bits 15..12 poolStringIndexLimit bits 27..24private static int
URES_INDEX_BUNDLE_TOP
[3] contains the top of the bundle, in case it were ever different from [2]private static int
URES_INDEX_KEYS_TOP
[1] contains the top of the key strings, same as the bottom of resources or UTF-16 strings, rounded upprivate static int
URES_INDEX_LENGTH
[0] contains the length of indexes[] which is at most URES_INDEX_TOP of the latest format version formatVersion==1: all bits contain the length of indexes[] but the length is much less than 0xff; formatVersion>1: only bits 7..0 contain the length of indexes[], bits 31..8 are reserved and set to 0 formatVersion>=3: bits 31..8 poolStringIndexLimit bits 23..0private static int
URES_INDEX_MAX_TABLE_LENGTH
[4] max.private static int
URES_INDEX_POOL_CHECKSUM
[7] checksum of the pool bundle (new in formatVersion 2.0, ICU 4.4)private boolean
usesPoolBundle
-
Constructor Summary
Constructors Modifier Constructor Description private
ICUResourceBundleReader()
private
ICUResourceBundleReader(java.nio.ByteBuffer inBytes, java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader loader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
compareKeys(java.lang.CharSequence key, char keyOffset)
private int
compareKeys32(java.lang.CharSequence key, int keyOffset)
(package private) java.lang.String
getAlias(int res)
(package private) ICUResourceBundleReader.Array
getArray(int res)
(package private) java.nio.ByteBuffer
getBinary(int res)
(package private) byte[]
getBinary(int res, byte[] ba)
private char[]
getChars(int offset, int count)
static java.lang.String
getFullName(java.lang.String baseName, java.lang.String localeName)
Gets the full name of the resource with suffix.private int
getIndexesInt(int i)
private int
getInt(int offset)
private int[]
getInts(int offset, int count)
(package private) int[]
getIntVector(int res)
private java.lang.String
getKey16String(int keyOffset)
private java.lang.String
getKey32String(int keyOffset)
(package private) boolean
getNoFallback()
(package private) static ICUResourceBundleReader
getReader(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root)
private int
getResourceByteOffset(int offset)
(package private) int
getRootResource()
(package private) java.lang.String
getString(int res)
(package private) java.lang.String
getStringV2(int res)
(package private) ICUResourceBundleReader.Table
getTable(int res)
private char[]
getTable16KeyOffsets(int offset)
private int[]
getTable32KeyOffsets(int offset)
private char[]
getTableKeyOffsets(int offset)
(package private) boolean
getUsesPoolBundle()
(package private) VersionInfo
getVersion()
private void
init(java.nio.ByteBuffer inBytes)
private boolean
isNoInheritanceMarker(int res)
CLDR string value "∅∅∅"=="∅∅∅" prevents fallback to the parent bundle.private boolean
isStringV2NoInheritanceMarker(int offset)
private static java.lang.String
makeKeyStringFromBytes(byte[] keyBytes, int keyOffset)
private java.lang.String
makeStringFromBytes(int offset, int length)
(package private) static int
RES_GET_INT(int res)
private static int
RES_GET_OFFSET(int res)
(package private) static int
RES_GET_TYPE(int res)
(package private) static int
RES_GET_UINT(int res)
private void
setKeyFromKey16(int keyOffset, UResource.Key key)
private void
setKeyFromKey32(int keyOffset, UResource.Key key)
(package private) static boolean
URES_IS_ARRAY(int type)
(package private) static boolean
URES_IS_TABLE(int type)
-
-
-
Field Detail
-
DATA_FORMAT
private static final int DATA_FORMAT
File format version that this class understands. "ResB"- See Also:
- Constant Field Values
-
IS_ACCEPTABLE
private static final ICUResourceBundleReader.IsAcceptable IS_ACCEPTABLE
-
URES_INDEX_LENGTH
private static final int URES_INDEX_LENGTH
[0] contains the length of indexes[] which is at most URES_INDEX_TOP of the latest format version formatVersion==1: all bits contain the length of indexes[] but the length is much less than 0xff; formatVersion>1: only bits 7..0 contain the length of indexes[], bits 31..8 are reserved and set to 0 formatVersion>=3: bits 31..8 poolStringIndexLimit bits 23..0- See Also:
- Constant Field Values
-
URES_INDEX_KEYS_TOP
private static final int URES_INDEX_KEYS_TOP
[1] contains the top of the key strings, same as the bottom of resources or UTF-16 strings, rounded up- See Also:
- Constant Field Values
-
URES_INDEX_BUNDLE_TOP
private static final int URES_INDEX_BUNDLE_TOP
[3] contains the top of the bundle, in case it were ever different from [2]- See Also:
- Constant Field Values
-
URES_INDEX_MAX_TABLE_LENGTH
private static final int URES_INDEX_MAX_TABLE_LENGTH
[4] max. length of any table- See Also:
- Constant Field Values
-
URES_INDEX_ATTRIBUTES
private static final int URES_INDEX_ATTRIBUTES
[5] attributes bit set, see URES_ATT_* (new in formatVersion 1.2) formatVersion>=3: bits 31..16 poolStringIndex16Limit bits 15..12 poolStringIndexLimit bits 27..24- See Also:
- Constant Field Values
-
URES_INDEX_16BIT_TOP
private static final int URES_INDEX_16BIT_TOP
[6] top of the 16-bit units (UTF-16 string v2 UChars, URES_TABLE16, URES_ARRAY16), rounded up (new in formatVersion 2.0, ICU 4.4)- See Also:
- Constant Field Values
-
URES_INDEX_POOL_CHECKSUM
private static final int URES_INDEX_POOL_CHECKSUM
[7] checksum of the pool bundle (new in formatVersion 2.0, ICU 4.4)- See Also:
- Constant Field Values
-
URES_ATT_NO_FALLBACK
private static final int URES_ATT_NO_FALLBACK
- See Also:
- Constant Field Values
-
URES_ATT_IS_POOL_BUNDLE
private static final int URES_ATT_IS_POOL_BUNDLE
- See Also:
- Constant Field Values
-
URES_ATT_USES_POOL_BUNDLE
private static final int URES_ATT_USES_POOL_BUNDLE
- See Also:
- Constant Field Values
-
EMPTY_16_BIT_UNITS
private static final java.nio.CharBuffer EMPTY_16_BIT_UNITS
-
LARGE_SIZE
static final int LARGE_SIZE
Objects with more value bytes are stored in SoftReferences. Smaller objects (which are not much larger than a SoftReference) are stored directly, avoiding the overhead of the reference.- See Also:
- Constant Field Values
-
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
-
dataVersion
private int dataVersion
-
bytes
private java.nio.ByteBuffer bytes
Buffer of all of the resource bundle bytes after the header. (equivalent of C++ pRoot)
-
keyBytes
private byte[] keyBytes
-
b16BitUnits
private java.nio.CharBuffer b16BitUnits
-
poolBundleReader
private ICUResourceBundleReader poolBundleReader
-
rootRes
private int rootRes
-
localKeyLimit
private int localKeyLimit
-
poolStringIndexLimit
private int poolStringIndexLimit
-
poolStringIndex16Limit
private int poolStringIndex16Limit
-
noFallback
private boolean noFallback
-
isPoolBundle
private boolean isPoolBundle
-
usesPoolBundle
private boolean usesPoolBundle
-
poolCheckSum
private int poolCheckSum
-
resourceCache
private ICUResourceBundleReader.ResourceCache resourceCache
-
CACHE
private static ICUResourceBundleReader.ReaderCache CACHE
-
NULL_READER
private static final ICUResourceBundleReader NULL_READER
-
emptyBytes
private static final byte[] emptyBytes
-
emptyByteBuffer
private static final java.nio.ByteBuffer emptyByteBuffer
-
emptyChars
private static final char[] emptyChars
-
emptyInts
private static final int[] emptyInts
-
emptyString
private static final java.lang.String emptyString
- See Also:
- Constant Field Values
-
EMPTY_ARRAY
private static final ICUResourceBundleReader.Array EMPTY_ARRAY
-
EMPTY_TABLE
private static final ICUResourceBundleReader.Table EMPTY_TABLE
-
PUBLIC_TYPES
private static int[] PUBLIC_TYPES
From C++ uresdata.c gPublicTypes[URES_LIMIT].
-
ICU_RESOURCE_SUFFIX
private static final java.lang.String ICU_RESOURCE_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ICUResourceBundleReader
private ICUResourceBundleReader()
-
ICUResourceBundleReader
private ICUResourceBundleReader(java.nio.ByteBuffer inBytes, java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader loader) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getReader
static ICUResourceBundleReader getReader(java.lang.String baseName, java.lang.String localeID, java.lang.ClassLoader root)
-
init
private void init(java.nio.ByteBuffer inBytes) throws java.io.IOException
- Throws:
java.io.IOException
-
getIndexesInt
private int getIndexesInt(int i)
-
getVersion
VersionInfo getVersion()
-
getRootResource
int getRootResource()
-
getNoFallback
boolean getNoFallback()
-
getUsesPoolBundle
boolean getUsesPoolBundle()
-
RES_GET_TYPE
static int RES_GET_TYPE(int res)
-
RES_GET_OFFSET
private static int RES_GET_OFFSET(int res)
-
getResourceByteOffset
private int getResourceByteOffset(int offset)
-
RES_GET_INT
static int RES_GET_INT(int res)
-
RES_GET_UINT
static int RES_GET_UINT(int res)
-
URES_IS_ARRAY
static boolean URES_IS_ARRAY(int type)
-
URES_IS_TABLE
static boolean URES_IS_TABLE(int type)
-
getChars
private char[] getChars(int offset, int count)
-
getInt
private int getInt(int offset)
-
getInts
private int[] getInts(int offset, int count)
-
getTable16KeyOffsets
private char[] getTable16KeyOffsets(int offset)
-
getTableKeyOffsets
private char[] getTableKeyOffsets(int offset)
-
getTable32KeyOffsets
private int[] getTable32KeyOffsets(int offset)
-
makeKeyStringFromBytes
private static java.lang.String makeKeyStringFromBytes(byte[] keyBytes, int keyOffset)
-
getKey16String
private java.lang.String getKey16String(int keyOffset)
-
getKey32String
private java.lang.String getKey32String(int keyOffset)
-
setKeyFromKey16
private void setKeyFromKey16(int keyOffset, UResource.Key key)
-
setKeyFromKey32
private void setKeyFromKey32(int keyOffset, UResource.Key key)
-
compareKeys
private int compareKeys(java.lang.CharSequence key, char keyOffset)
-
compareKeys32
private int compareKeys32(java.lang.CharSequence key, int keyOffset)
-
getStringV2
java.lang.String getStringV2(int res)
- Returns:
- a string from the local bundle's b16BitUnits at the local offset
-
makeStringFromBytes
private java.lang.String makeStringFromBytes(int offset, int length)
-
getString
java.lang.String getString(int res)
-
isNoInheritanceMarker
private boolean isNoInheritanceMarker(int res)
CLDR string value "∅∅∅"=="∅∅∅" prevents fallback to the parent bundle.
-
isStringV2NoInheritanceMarker
private boolean isStringV2NoInheritanceMarker(int offset)
-
getAlias
java.lang.String getAlias(int res)
-
getBinary
byte[] getBinary(int res, byte[] ba)
-
getBinary
java.nio.ByteBuffer getBinary(int res)
-
getIntVector
int[] getIntVector(int res)
-
getArray
ICUResourceBundleReader.Array getArray(int res)
-
getTable
ICUResourceBundleReader.Table getTable(int res)
-
getFullName
public static java.lang.String getFullName(java.lang.String baseName, java.lang.String localeName)
Gets the full name of the resource with suffix.
-
-