Class ICUBinary


  • public final class ICUBinary
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ICUBinary.Authenticate
      Special interface for data authentication
    • Constructor Summary

      Constructors 
      Constructor Description
      ICUBinary()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] readHeader​(java.io.InputStream inputStream, byte[] dataFormatIDExpected, ICUBinary.Authenticate authenticate)
      ICU data header reader method.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ICUBinary

        public ICUBinary()
    • Method Detail

      • readHeader

        public static final byte[] readHeader​(java.io.InputStream inputStream,
                                              byte[] dataFormatIDExpected,
                                              ICUBinary.Authenticate authenticate)
                                       throws java.io.IOException

        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:
        java.io.IOException - thrown if there is a read error or when header authentication fails.