public final class

ICUBinary

extends Object
java.lang.Object
   ↳ sun.text.normalizer.ICUBinary

Summary

Nested Classes
interface ICUBinary.Authenticate Special interface for data authentication  
Public Constructors
ICUBinary()
Public Methods
final static byte[] readHeader(InputStream inputStream, byte[] dataFormatIDExpected, ICUBinary.Authenticate authenticate)

ICU data header reader method.

[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ICUBinary ()

Public Methods

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

ICU data header reader method. Takes a ICU generated big-endian input stream, parse the ICU standard file header and authenticates them.

Header format:

  • Header size (char)
  • Magic number 1 (byte)
  • Magic number 2 (byte)
  • Rest of the header size (char)
  • Reserved word (char)
  • Big endian indicator (byte)
  • Character set family indicator (byte)
  • Size of a char (byte) for c++ and c use
  • Reserved byte (byte)
  • Data format identifier (4 bytes), each ICU data has its own identifier to distinguish them. [0] major [1] minor [2] milli [3] micro
  • Data version (4 bytes), the change version of the ICU data [0] major [1] minor [2] milli [3] micro
  • Unicode version (4 bytes) this ICU is based on.

Example of use:

 try {
    FileInputStream input = new FileInputStream(filename);
    If (Utility.readICUDataHeader(input, dataformat, dataversion,
                                  unicode) {
        System.out.println("Verified file header, this is a ICU data file");
    }
 } catch (IOException e) {
    System.out.println("This is not a ICU data file");
 }
 

Parameters
inputStream input stream that contains the ICU data header
dataFormatIDExpected Data format expected. An array of 4 bytes information about the data format. E.g. data format ID 1.2.3.4. will became an array of {1, 2, 3, 4}
authenticate user defined extra data authentication. This value can be null, if no extra authentication is needed.
Throws
IOException thrown if there is a read error or when header authentication fails.