From 69f48a98d3ae685d13befc496c3c2609c4661679 Mon Sep 17 00:00:00 2001 From: Syn Wee Quek Date: Thu, 1 Aug 2002 19:50:34 +0000 Subject: [PATCH] ICU-2047 Removed restriction on Unicode versions X-SVN-Rev: 9516 --- icu4j/src/com/ibm/icu/impl/ICUBinary.java | 15 +++++++-------- .../com/ibm/icu/impl/NormalizerDataReader.java | 10 +++------- .../ibm/icu/impl/UCharacterPropertyReader.java | 15 +++++++-------- .../com/ibm/icu/lang/UCharacterNameReader.java | 11 ++++------- icu4j/src/com/ibm/icu/text/CollatorReader.java | 12 +++++------- 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/icu4j/src/com/ibm/icu/impl/ICUBinary.java b/icu4j/src/com/ibm/icu/impl/ICUBinary.java index 41e235820ab..c5f2472e29e 100755 --- a/icu4j/src/com/ibm/icu/impl/ICUBinary.java +++ b/icu4j/src/com/ibm/icu/impl/ICUBinary.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/ICUBinary.java,v $ - * $Date: 2002/03/10 19:40:15 $ - * $Revision: 1.5 $ + * $Date: 2002/08/01 19:50:26 $ + * $Revision: 1.6 $ * ***************************************************************************************** */ package com.ibm.icu.impl; @@ -73,10 +73,9 @@ public final class ICUBinary * when header authentication fails. * @draft 2.1 */ - public static final void readHeader(InputStream inputStream, + public static final byte[] readHeader(InputStream inputStream, byte dataFormatIDExpected[], - byte dataVersionExpected[], - byte unicodeVersionExpected[]) + byte dataVersionExpected[]) throws IOException { DataInputStream input = new DataInputStream(inputStream); @@ -116,12 +115,12 @@ public final class ICUBinary input.skipBytes(headersize); if (bigendian != BIG_ENDIAN_ || charset != CHAR_SET_ || - charsize != CHAR_SIZE_ || + charsize != CHAR_SIZE_ || !Arrays.equals(dataFormatIDExpected, dataFormatID) || - !Arrays.equals(dataVersionExpected, dataVersion) || - !Arrays.equals(unicodeVersionExpected, unicodeVersion)) { + !Arrays.equals(dataVersionExpected, dataVersion)) { throw new IOException(HEADER_AUTHENTICATION_FAILED_); } + return unicodeVersion; } // private variables ------------------------------------------------- diff --git a/icu4j/src/com/ibm/icu/impl/NormalizerDataReader.java b/icu4j/src/com/ibm/icu/impl/NormalizerDataReader.java index fc4eebba0ba..c79138f2aab 100644 --- a/icu4j/src/com/ibm/icu/impl/NormalizerDataReader.java +++ b/icu4j/src/com/ibm/icu/impl/NormalizerDataReader.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/NormalizerDataReader.java,v $ - * $Date: 2002/07/30 02:32:56 $ - * $Revision: 1.6 $ + * $Date: 2002/08/01 19:50:26 $ + * $Revision: 1.7 $ ******************************************************************************* */ @@ -290,7 +290,7 @@ final class NormalizerDataReader { if(debug) System.out.println("Bytes in inputStream " + inputStream.available()); ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, - DATA_FORMAT_VERSION, UNICODE_VERSION); + DATA_FORMAT_VERSION); if(debug) System.out.println("Bytes left in inputStream " +inputStream.available()); @@ -394,9 +394,5 @@ final class NormalizerDataReader { (byte)0x72, (byte)0x6D}; private static final byte DATA_FORMAT_VERSION[] = {(byte)0x2, (byte)0x1, (byte)0x5, (byte)0x2}; - //TODO: Set the version info after the VersionInfo class is ported - private static final byte UNICODE_VERSION[] = {(byte)0x3, (byte)0x2, - (byte)0x0, (byte)0x0}; - private static final String UNICODE_VERSION_STRING = "3.2.0.0"; } diff --git a/icu4j/src/com/ibm/icu/impl/UCharacterPropertyReader.java b/icu4j/src/com/ibm/icu/impl/UCharacterPropertyReader.java index 05146b21aef..f35186e3af4 100644 --- a/icu4j/src/com/ibm/icu/impl/UCharacterPropertyReader.java +++ b/icu4j/src/com/ibm/icu/impl/UCharacterPropertyReader.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/impl/UCharacterPropertyReader.java,v $ -* $Date: 2002/07/30 02:32:55 $ -* $Revision: 1.5 $ +* $Date: 2002/08/01 19:50:26 $ +* $Revision: 1.6 $ * ******************************************************************************* */ @@ -47,8 +47,8 @@ final class UCharacterPropertyReader protected UCharacterPropertyReader(InputStream inputStream) throws IOException { - ICUBinary.readHeader(inputStream, DATA_FORMAT_ID_, - DATA_FORMAT_VERSION_, UNICODE_VERSION_); + m_unicodeVersion_ = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID_, + DATA_FORMAT_VERSION_); m_dataInputStream_ = new DataInputStream(inputStream); } @@ -120,8 +120,8 @@ final class UCharacterPropertyReader m_dataInputStream_.close(); ucharppty.m_additionalColumnsCount_ = m_additionalColumnsCount_; ucharppty.m_unicodeVersion_ = VersionInfo.getInstance( - (int)UNICODE_VERSION_[0], (int)UNICODE_VERSION_[1], - (int)UNICODE_VERSION_[2], (int)UNICODE_VERSION_[3]); + (int)m_unicodeVersion_[0], (int)m_unicodeVersion_[1], + (int)m_unicodeVersion_[2], (int)m_unicodeVersion_[3]); } // private variables ------------------------------------------------- @@ -146,6 +146,7 @@ final class UCharacterPropertyReader private int m_additionalVectorsOffset_; private int m_additionalColumnsCount_; private int m_reservedOffset_; + private byte m_unicodeVersion_[]; /** * File format version that this class understands. @@ -156,6 +157,4 @@ final class UCharacterPropertyReader private static final byte DATA_FORMAT_VERSION_[] = {(byte)0x3, (byte)0x1, (byte)Trie.INDEX_STAGE_1_SHIFT_, (byte)Trie.INDEX_STAGE_2_SHIFT_}; - private static final byte UNICODE_VERSION_[] = {(byte)0x3, (byte)0x2, - (byte)0x0, (byte)0x0}; } diff --git a/icu4j/src/com/ibm/icu/lang/UCharacterNameReader.java b/icu4j/src/com/ibm/icu/lang/UCharacterNameReader.java index 79f87b214cb..22471ba057e 100755 --- a/icu4j/src/com/ibm/icu/lang/UCharacterNameReader.java +++ b/icu4j/src/com/ibm/icu/lang/UCharacterNameReader.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/lang/Attic/UCharacterNameReader.java,v $ -* $Date: 2002/07/30 02:38:11 $ -* $Revision: 1.10 $ +* $Date: 2002/08/01 19:50:26 $ +* $Revision: 1.11 $ * ******************************************************************************* */ @@ -49,7 +49,7 @@ final class UCharacterNameReader throws IOException { ICUBinary.readHeader(inputStream, DATA_FORMAT_ID_, - DATA_FORMAT_VERSION_, UNICODE_VERSION_); + DATA_FORMAT_VERSION_); m_dataInputStream_ = new DataInputStream(inputStream); } @@ -158,10 +158,7 @@ final class UCharacterNameReader private static final byte DATA_FORMAT_VERSION_[] = {(byte)0x1, (byte)0x0, (byte)0x0, (byte)0x0}; private static final byte DATA_FORMAT_ID_[] = {(byte)0x75, (byte)0x6E, - (byte)0x61, (byte)0x6D}; - private static final byte UNICODE_VERSION_[] = {(byte)0x3, (byte)0x2, - (byte)0x0, (byte)0x0}; - + (byte)0x61, (byte)0x6D}; /** * Corrupted error string */ diff --git a/icu4j/src/com/ibm/icu/text/CollatorReader.java b/icu4j/src/com/ibm/icu/text/CollatorReader.java index 46148880e72..6bcda46d363 100644 --- a/icu4j/src/com/ibm/icu/text/CollatorReader.java +++ b/icu4j/src/com/ibm/icu/text/CollatorReader.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/CollatorReader.java,v $ -* $Date: 2002/07/30 02:38:12 $ -* $Revision: 1.5 $ +* $Date: 2002/08/01 19:50:34 $ +* $Revision: 1.6 $ * ******************************************************************************* */ @@ -45,7 +45,7 @@ final class CollatorReader protected CollatorReader(InputStream inputStream) throws IOException { ICUBinary.readHeader(inputStream, DATA_FORMAT_ID_, - DATA_FORMAT_VERSION_, UNICODE_VERSION_); + DATA_FORMAT_VERSION_); m_dataInputStream_ = new DataInputStream(inputStream); } @@ -61,7 +61,7 @@ final class CollatorReader { if (readICUHeader) { ICUBinary.readHeader(inputStream, DATA_FORMAT_ID_, - DATA_FORMAT_VERSION_, UNICODE_VERSION_); + DATA_FORMAT_VERSION_); } m_dataInputStream_ = new DataInputStream(inputStream); } @@ -345,7 +345,7 @@ final class CollatorReader throws IOException { ICUBinary.readHeader(inputStream, INVERSE_UCA_DATA_FORMAT_ID_, - DATA_FORMAT_VERSION_, UNICODE_VERSION_); + DATA_FORMAT_VERSION_); CollationParsedRuleBuilder.InverseUCA result = new CollationParsedRuleBuilder.InverseUCA(); DataInputStream input = new DataInputStream(inputStream); @@ -385,8 +385,6 @@ final class CollatorReader {(byte)0x2, (byte)0x0, (byte)0x0, (byte)0x0}; private static final byte DATA_FORMAT_ID_[] = {(byte)0x55, (byte)0x43, (byte)0x6f, (byte)0x6c}; - private static final byte UNICODE_VERSION_[] = {(byte)0x3, (byte)0x0, - (byte)0x0, (byte)0x0}; /** * Inverse UCA file format version and id that this class understands. * No guarantees are made if a older version is used