< prev index next >

src/java.base/share/classes/jdk/internal/icu/impl/StringPrepDataReader.java

Print this page
rev 58552 : [mq]: 8241727-Typos-empty-lines-in-javadoc-inconsistent-indents-etc


  59    /**
  60     * <p>private constructor.</p>
  61     * @param inputStream ICU uprop.dat file input stream
  62     * @exception IOException throw if data file fails authentication
  63     * @draft 2.1
  64     */
  65     public StringPrepDataReader(InputStream inputStream)
  66                                         throws IOException{
  67 
  68         unicodeVersion = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
  69 
  70 
  71         dataInputStream = new DataInputStream(inputStream);
  72 
  73     }
  74 
  75     public void read(byte[] idnaBytes,
  76                         char[] mappingTable)
  77                         throws IOException{
  78 
  79         //Read the bytes that make up the idnaTrie
  80         dataInputStream.read(idnaBytes);
  81 
  82         //Read the extra data
  83         for(int i=0;i<mappingTable.length;i++){
  84             mappingTable[i]=dataInputStream.readChar();
  85         }
  86     }
  87 
  88     public byte[] getDataFormatVersion(){
  89         return DATA_FORMAT_VERSION;
  90     }
  91 
  92     public boolean isDataVersionAcceptable(byte version[]){
  93         return version[0] == DATA_FORMAT_VERSION[0]
  94                && version[2] == DATA_FORMAT_VERSION[2]
  95                && version[3] == DATA_FORMAT_VERSION[3];
  96     }
  97     public int[] readIndexes(int length)throws IOException{
  98         int[] indexes = new int[length];
  99         //Read the indexes
 100         for (int i = 0; i <length ; i++) {
 101              indexes[i] = dataInputStream.readInt();
 102         }
 103         return indexes;
 104     }
 105 
 106     public byte[] getUnicodeVersion(){
 107         return unicodeVersion;
 108     }
 109     // private data members -------------------------------------------------
 110 
 111 
 112     /**
 113     * ICU data file input stream
 114     */
 115     private DataInputStream dataInputStream;
 116     private byte[] unicodeVersion;
 117     /**
 118     * File format version that this class understands.
 119     * No guarantees are made if a older version is used
 120     * see store.c of gennorm for more information and values
 121     */
 122     ///* dataFormat="SPRP" 0x53, 0x50, 0x52, 0x50  */
 123     private static final byte DATA_FORMAT_ID[] = {(byte)0x53, (byte)0x50,
 124                                                     (byte)0x52, (byte)0x50};
 125     private static final byte DATA_FORMAT_VERSION[] = {(byte)0x3, (byte)0x2,
 126                                                         (byte)0x5, (byte)0x2};
 127 
 128 }


  59    /**
  60     * <p>private constructor.</p>
  61     * @param inputStream ICU uprop.dat file input stream
  62     * @exception IOException throw if data file fails authentication
  63     * @draft 2.1
  64     */
  65     public StringPrepDataReader(InputStream inputStream)
  66                                         throws IOException{
  67 
  68         unicodeVersion = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
  69 
  70 
  71         dataInputStream = new DataInputStream(inputStream);
  72 
  73     }
  74 
  75     public void read(byte[] idnaBytes,
  76                         char[] mappingTable)
  77                         throws IOException{
  78 
  79         // Read the bytes that make up the idnaTrie
  80         dataInputStream.read(idnaBytes);
  81 
  82         // Read the extra data
  83         for(int i=0;i<mappingTable.length;i++){
  84             mappingTable[i]=dataInputStream.readChar();
  85         }
  86     }
  87 
  88     public byte[] getDataFormatVersion(){
  89         return DATA_FORMAT_VERSION;
  90     }
  91 
  92     public boolean isDataVersionAcceptable(byte version[]){
  93         return version[0] == DATA_FORMAT_VERSION[0]
  94                && version[2] == DATA_FORMAT_VERSION[2]
  95                && version[3] == DATA_FORMAT_VERSION[3];
  96     }
  97     public int[] readIndexes(int length) throws IOException{
  98         int[] indexes = new int[length];
  99         // Read the indexes
 100         for (int i = 0; i <length ; i++) {
 101              indexes[i] = dataInputStream.readInt();
 102         }
 103         return indexes;
 104     }
 105 
 106     public byte[] getUnicodeVersion(){
 107         return unicodeVersion;
 108     }
 109     // private data members -------------------------------------------------
 110 
 111 
 112     /**
 113      * ICU data file input stream
 114      */
 115     private DataInputStream dataInputStream;
 116     private byte[] unicodeVersion;
 117     /**
 118      * File format version that this class understands.
 119      * No guarantees are made if a older version is used
 120      * see store.c of gennorm for more information and values
 121      */
 122     ///* dataFormat="SPRP" 0x53, 0x50, 0x52, 0x50  */
 123     private static final byte DATA_FORMAT_ID[] = {(byte)0x53, (byte)0x50,
 124                                                     (byte)0x52, (byte)0x50};
 125     private static final byte DATA_FORMAT_VERSION[] = {(byte)0x3, (byte)0x2,
 126                                                         (byte)0x5, (byte)0x2};
 127 
 128 }
< prev index next >