2 ******************************************************************************
3 * Copyright (C) 2003-2008, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 ******************************************************************************
7 * Created on May 2, 2003
9 * To change the template for this generated file go to
10 * Window>Preferences>Java>Code Generation>Code and Comments
12 package com.ibm.icu.impl;
14 import java.io.DataInputStream;
15 import java.io.IOException;
16 import java.io.InputStream;
23 * To change the template for this generated type comment go to
24 * Window>Preferences>Java>Code Generation>Code and Comments
26 public final class StringPrepDataReader implements ICUBinary.Authenticate {
27 private final static boolean debug = ICUDebug.enabled("NormalizerDataReader");
30 * <p>private constructor.</p>
31 * @param inputStream ICU uprop.dat file input stream
32 * @exception IOException throw if data file fails authentication
34 public StringPrepDataReader(InputStream inputStream)
36 if(debug) System.out.println("Bytes in inputStream " + inputStream.available());
38 unicodeVersion = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
40 if(debug) System.out.println("Bytes left in inputStream " +inputStream.available());
42 dataInputStream = new DataInputStream(inputStream);
44 if(debug) System.out.println("Bytes left in dataInputStream " +dataInputStream.available());
47 public void read(byte[] idnaBytes,
51 //Read the bytes that make up the idnaTrie
52 dataInputStream.readFully(idnaBytes);
55 for(int i=0;i<mappingTable.length;i++){
56 mappingTable[i]=dataInputStream.readChar();
60 public byte[] getDataFormatVersion(){
61 return DATA_FORMAT_VERSION;
64 public boolean isDataVersionAcceptable(byte version[]){
65 return version[0] == DATA_FORMAT_VERSION[0]
66 && version[2] == DATA_FORMAT_VERSION[2]
67 && version[3] == DATA_FORMAT_VERSION[3];
69 public int[] readIndexes(int length)throws IOException{
70 int[] indexes = new int[length];
72 for (int i = 0; i <length ; i++) {
73 indexes[i] = dataInputStream.readInt();
78 public byte[] getUnicodeVersion(){
79 return unicodeVersion;
81 // private data members -------------------------------------------------
85 * ICU data file input stream
87 private DataInputStream dataInputStream;
88 private byte[] unicodeVersion;
90 * File format version that this class understands.
91 * No guarantees are made if a older version is used
92 * see store.c of gennorm for more information and values
94 ///* dataFormat="SPRP" 0x53, 0x50, 0x52, 0x50 */
95 private static final byte DATA_FORMAT_ID[] = {(byte)0x53, (byte)0x50,
96 (byte)0x52, (byte)0x50};
97 private static final byte DATA_FORMAT_VERSION[] = {(byte)0x3, (byte)0x2,
98 (byte)0x5, (byte)0x2};