Class 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.
    • Field Detail

      • DATA_FORMAT

        private static final int DATA_FORMAT
        File format version that this class understands. "ResB"
        See Also:
        Constant Field Values
      • 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_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
      • 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
      • 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
      • 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
      • 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)
      • 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)
      • getFullName

        public static java.lang.String getFullName​(java.lang.String baseName,
                                                   java.lang.String localeName)
        Gets the full name of the resource with suffix.