public final class ICUBinary extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ICUBinary.Authenticate
Special interface for data authentication
|
| Constructor and Description |
|---|
ICUBinary() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addBaseNamesInFileFolder(String folder,
String suffix,
Set<String> names) |
static ByteBuffer |
getByteBufferFromInputStreamAndCloseStream(InputStream is)
Reads the entire contents from the stream into a byte array
and wraps it into a ByteBuffer.
|
static byte[] |
getBytes(ByteBuffer bytes,
int length,
int additionalSkipLength) |
static char[] |
getChars(ByteBuffer bytes,
int length,
int additionalSkipLength) |
static ByteBuffer |
getData(ClassLoader loader,
String resourceName,
String itemPath)
Loads an ICU binary data file and returns it as a ByteBuffer.
|
static ByteBuffer |
getData(String itemPath)
Loads an ICU binary data file and returns it as a ByteBuffer.
|
static int[] |
getInts(ByteBuffer bytes,
int length,
int additionalSkipLength) |
static long[] |
getLongs(ByteBuffer bytes,
int length,
int additionalSkipLength) |
static ByteBuffer |
getRequiredData(String itemPath)
Loads an ICU binary data file and returns it as a ByteBuffer.
|
static short[] |
getShorts(ByteBuffer bytes,
int length,
int additionalSkipLength) |
static String |
getString(ByteBuffer bytes,
int length,
int additionalSkipLength) |
static byte[] |
getVersionByteArrayFromCompactInt(int version)
Returns an array of the bytes in the compact version integer.
|
static VersionInfo |
getVersionInfoFromCompactInt(int version)
Returns a VersionInfo for the bytes in the compact version integer.
|
static int |
readHeader(ByteBuffer bytes,
int dataFormat,
ICUBinary.Authenticate authenticate)
Reads an ICU data header, checks the data format, and returns the data version.
|
static VersionInfo |
readHeaderAndDataVersion(ByteBuffer bytes,
int dataFormat,
ICUBinary.Authenticate authenticate)
Same as readHeader(), but returns a VersionInfo rather than a compact int.
|
static void |
skipBytes(ByteBuffer bytes,
int skipLength) |
static ByteBuffer |
sliceWithOrder(ByteBuffer bytes)
Same as ByteBuffer.slice() plus preserving the byte order.
|
static int |
writeHeader(int dataFormat,
int formatVersion,
int dataVersion,
DataOutputStream dos)
Writes an ICU data header.
|
public static ByteBuffer getData(String itemPath)
itemPath - Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".public static ByteBuffer getData(ClassLoader loader, String resourceName, String itemPath)
loader - Used for loader.getResourceAsStream() unless the data is found elsewhere.resourceName - Resource name for use with the loader.itemPath - Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".public static ByteBuffer getRequiredData(String itemPath)
itemPath - Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".MissingResourceException - if required==true and the resource could not be foundpublic static void addBaseNamesInFileFolder(String folder, String suffix, Set<String> names)
folder - The relative ICU data folder, like "" or "coll".suffix - Usually ".res".names - File base names relative to the folder are added without the suffix,
for example "de_CH".public static VersionInfo readHeaderAndDataVersion(ByteBuffer bytes, int dataFormat, ICUBinary.Authenticate authenticate) throws IOException
IOExceptionpublic static int readHeader(ByteBuffer bytes, int dataFormat, ICUBinary.Authenticate authenticate) throws IOException
Assumes that the ByteBuffer position is 0 on input. The buffer byte order is set according to the data. The buffer position is advanced past the header (including UDataInfo and comment).
See C++ ucmndata.h and unicode/udata.h.
IOException - if this is not a valid ICU data item of the expected dataFormatpublic static int writeHeader(int dataFormat,
int formatVersion,
int dataVersion,
DataOutputStream dos)
throws IOException
IOException - from the DataOutputStreampublic static void skipBytes(ByteBuffer bytes, int skipLength)
public static byte[] getBytes(ByteBuffer bytes, int length, int additionalSkipLength)
public static String getString(ByteBuffer bytes, int length, int additionalSkipLength)
public static char[] getChars(ByteBuffer bytes, int length, int additionalSkipLength)
public static short[] getShorts(ByteBuffer bytes, int length, int additionalSkipLength)
public static int[] getInts(ByteBuffer bytes, int length, int additionalSkipLength)
public static long[] getLongs(ByteBuffer bytes, int length, int additionalSkipLength)
public static ByteBuffer sliceWithOrder(ByteBuffer bytes)
public static ByteBuffer getByteBufferFromInputStreamAndCloseStream(InputStream is) throws IOException
IOExceptionpublic static VersionInfo getVersionInfoFromCompactInt(int version)
public static byte[] getVersionByteArrayFromCompactInt(int version)