0N/A/*
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A/*
0N/A/*
0N/A ******************************************************************************
0N/A * Copyright (C) 2003, International Business Machines Corporation and *
0N/A * others. All Rights Reserved. *
0N/A ******************************************************************************
0N/A *
0N/A * Created on May 2, 2003
0N/A *
0N/A * To change the template for this generated file go to
0N/A * Window>Preferences>Java>Code Generation>Code and Comments
0N/A */
0N/A// CHANGELOG
0N/A// 2005-05-19 Edward Wang
0N/A// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/impl/StringPrepDataReader.java
0N/A// - move from package com.ibm.icu.impl to package sun.net.idn
0N/A//
0N/Apackage sun.net.idn;
0N/A
0N/Aimport java.io.DataInputStream;
0N/Aimport java.io.IOException;
0N/Aimport java.io.InputStream;
0N/A
0N/Aimport sun.text.normalizer.ICUBinary;
0N/A
0N/A
0N/A/**
0N/A * @author ram
0N/A *
0N/A * To change the template for this generated type comment go to
0N/A * Window>Preferences>Java>Code Generation>Code and Comments
0N/A */
0N/Afinal class StringPrepDataReader implements ICUBinary.Authenticate {
0N/A
0N/A /**
0N/A * <p>private constructor.</p>
0N/A * @param inputStream ICU uprop.dat file input stream
0N/A * @exception IOException throw if data file fails authentication
0N/A * @draft 2.1
0N/A */
0N/A public StringPrepDataReader(InputStream inputStream)
0N/A throws IOException{
0N/A
0N/A unicodeVersion = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
0N/A
0N/A
0N/A dataInputStream = new DataInputStream(inputStream);
0N/A
0N/A }
0N/A
0N/A public void read(byte[] idnaBytes,
0N/A char[] mappingTable)
0N/A throws IOException{
0N/A
0N/A //Read the bytes that make up the idnaTrie
0N/A dataInputStream.read(idnaBytes);
0N/A
0N/A //Read the extra data
0N/A for(int i=0;i<mappingTable.length;i++){
0N/A mappingTable[i]=dataInputStream.readChar();
0N/A }
0N/A }
0N/A
0N/A public byte[] getDataFormatVersion(){
0N/A return DATA_FORMAT_VERSION;
0N/A }
0N/A
0N/A public boolean isDataVersionAcceptable(byte version[]){
0N/A return version[0] == DATA_FORMAT_VERSION[0]
0N/A && version[2] == DATA_FORMAT_VERSION[2]
0N/A && version[3] == DATA_FORMAT_VERSION[3];
0N/A }
0N/A public int[] readIndexes(int length)throws IOException{
0N/A int[] indexes = new int[length];
0N/A //Read the indexes
0N/A for (int i = 0; i <length ; i++) {
0N/A indexes[i] = dataInputStream.readInt();
0N/A }
0N/A return indexes;
0N/A }
0N/A
0N/A public byte[] getUnicodeVersion(){
0N/A return unicodeVersion;
0N/A }
0N/A // private data members -------------------------------------------------
0N/A
0N/A
0N/A /**
0N/A * ICU data file input stream
0N/A */
0N/A private DataInputStream dataInputStream;
0N/A private byte[] unicodeVersion;
0N/A /**
0N/A * File format version that this class understands.
0N/A * No guarantees are made if a older version is used
0N/A * see store.c of gennorm for more information and values
0N/A */
0N/A ///* dataFormat="SPRP" 0x53, 0x50, 0x52, 0x50 */
0N/A private static final byte DATA_FORMAT_ID[] = {(byte)0x53, (byte)0x50,
0N/A (byte)0x52, (byte)0x50};
0N/A private static final byte DATA_FORMAT_VERSION[] = {(byte)0x3, (byte)0x2,
0N/A (byte)0x5, (byte)0x2};
0N/A
0N/A}