Top Inners Fields Constructors Methods
jdk.internal.icu.impl

public final Class ICUBinary

extends Object
Class Inheritance
Imports
java.io.DataInputStream, .InputStream, .IOException, .UncheckedIOException, java.nio.ByteBuffer, .ByteOrder, java.util.Arrays, java.security.AccessController, .PrivilegedAction, jdk.internal.icu.util.VersionInfo

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ICUBinary.Authenticate

Special interface for data authentication

private static class

Field Summary

Modifier and TypeField and Description
private static final byte
private static final byte
CHAR_SET_

File format authentication values

private static final byte
private static final String
private static final byte
MAGIC1

Magic numbers to authenticate the data file

private static final byte
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static byte[]
getBytes(ByteBuffer bytes, int length, int additionalSkipLength)

public static char[]
getChars(ByteBuffer bytes, int length, int additionalSkipLength)

public static int[]
getInts(ByteBuffer bytes, int length, int additionalSkipLength)

public static ByteBuffer

Returns:

The data as a read-only ByteBuffer.
getRequiredData
(String
Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".
itemPath
)

Loads an ICU binary data file and returns it as a ByteBuffer.

public static String
getString(ByteBuffer bytes, int length, int additionalSkipLength)

public static VersionInfo
getVersionInfoFromCompactInt(int version)

Returns a VersionInfo for the bytes in the compact version integer.

public static final byte[]
readHeader(InputStream inputStream, byte[] dataFormatIDExpected, ICUBinary.Authenticate authenticate)

public static int

Returns:

dataVersion
readHeader
(ByteBuffer bytes, int dataFormat, ICUBinary.Authenticate authenticate)

Reads an ICU data header, checks the data format, and returns the data version.

public static VersionInfo
readHeaderAndDataVersion(ByteBuffer bytes, int dataFormat, ICUBinary.Authenticate authenticate)

Same as readHeader(), but returns a VersionInfo rather than a compact int.

public static void
skipBytes(ByteBuffer bytes, int skipLength)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIG_ENDIAN_back to summary
private static final byte BIG_ENDIAN_
CHAR_SET_back to summary
private static final byte CHAR_SET_

File format authentication values

CHAR_SIZE_back to summary
private static final byte CHAR_SIZE_
HEADER_AUTHENTICATION_FAILED_back to summary
private static final String HEADER_AUTHENTICATION_FAILED_
MAGIC1back to summary
private static final byte MAGIC1

Magic numbers to authenticate the data file

MAGIC2back to summary
private static final byte MAGIC2
MAGIC_NUMBER_AUTHENTICATION_FAILED_back to summary
private static final String MAGIC_NUMBER_AUTHENTICATION_FAILED_

Error messages

Constructor Detail

ICUBinaryback to summary
public ICUBinary()

Method Detail

getBytesback to summary
public static byte[] getBytes(ByteBuffer bytes, int length, int additionalSkipLength)
getCharsback to summary
public static char[] getChars(ByteBuffer bytes, int length, int additionalSkipLength)
getIntsback to summary
public static int[] getInts(ByteBuffer bytes, int length, int additionalSkipLength)
getRequiredDataback to summary
public static ByteBuffer getRequiredData(String itemPath)

Loads an ICU binary data file and returns it as a ByteBuffer. The buffer contents is normally read-only, but its position etc. can be modified.

Parameters
itemPath:String

Relative ICU data item path, for example "root.res" or "coll/ucadata.icu".

Returns:ByteBuffer

The data as a read-only ByteBuffer.

getStringback to summary
public static String getString(ByteBuffer bytes, int length, int additionalSkipLength)
getVersionInfoFromCompactIntback to summary
public static VersionInfo getVersionInfoFromCompactInt(int version)

Returns a VersionInfo for the bytes in the compact version integer.

readHeaderback to summary
public static final byte[] readHeader(InputStream inputStream, byte[] dataFormatIDExpected, ICUBinary.Authenticate authenticate) throws IOException
readHeaderback to summary
public static int readHeader(ByteBuffer bytes, int dataFormat, ICUBinary.Authenticate authenticate) throws IOException

Reads an ICU data header, checks the data format, and returns the data version.

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.

Returns:int

dataVersion

Exceptions
IOException:
if this is not a valid ICU data item of the expected dataFormat
readHeaderAndDataVersionback to summary
public static VersionInfo readHeaderAndDataVersion(ByteBuffer bytes, int dataFormat, ICUBinary.Authenticate authenticate) throws IOException

Same as readHeader(), but returns a VersionInfo rather than a compact int.

skipBytesback to summary
public static void skipBytes(ByteBuffer bytes, int skipLength)
jdk.internal.icu.impl back to summary

public Interface ICUBinary.Authenticate

Known Direct Implementers
jdk.internal.icu.impl.NormalizerImpl.IsAcceptable, jdk.internal.icu.impl.StringPrepDataReader, jdk.internal.icu.impl.UBiDiProps.IsAcceptable, jdk.internal.icu.impl.UCharacterProperty.IsAcceptable, jdk.internal.icu.impl.ICUBinary.IsAcceptable

Special interface for data authentication

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if dataformat is an acceptable version, false otherwise
isDataVersionAcceptable
(byte[]
version of the current data
version
)

Method used in ICUBinary.readHeader() to provide data format authentication.

Method Detail

isDataVersionAcceptableback to summary
public boolean isDataVersionAcceptable(byte[] version)

Method used in ICUBinary.readHeader() to provide data format authentication.

Parameters
version:byte[]

version of the current data

Returns:boolean

true if dataformat is an acceptable version, false otherwise

jdk.internal.icu.impl back to summary

private final Class ICUBinary.IsAcceptable

extends Object
implements Authenticate
Class Inheritance
All Implemented Interfaces
jdk.internal.icu.impl.ICUBinary.Authenticate

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
isDataVersionAcceptable(byte[]
version of the current data
version
)

Implements jdk.internal.icu.impl.ICUBinary.Authenticate.isDataVersionAcceptable.

Method used in ICUBinary.readHeader() to provide data format authentication.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IsAcceptableback to summary
private IsAcceptable()

Method Detail

isDataVersionAcceptableback to summary
public boolean isDataVersionAcceptable(byte[] version)

Implements jdk.internal.icu.impl.ICUBinary.Authenticate.isDataVersionAcceptable.

Doc from jdk.internal.icu.impl.ICUBinary.Authenticate.isDataVersionAcceptable.

Method used in ICUBinary.readHeader() to provide data format authentication.

Parameters
version:byte[]

version of the current data

Returns:boolean

true if dataformat is an acceptable version, false otherwise

Annotations
@Override