195 * closed after the method returns.
196 *
197 * @param inputStream The stream for reading the StringPrep profile binarySun
198 * @throws IOException
199 * @draft ICU 2.8
200 */
201 public StringPrep(InputStream inputStream) throws IOException{
202
203 BufferedInputStream b = new BufferedInputStream(inputStream,DATA_BUFFER_SIZE);
204
205 StringPrepDataReader reader = new StringPrepDataReader(b);
206
207 // read the indexes
208 indexes = reader.readIndexes(INDEX_TOP);
209
210 byte[] sprepBytes = new byte[indexes[INDEX_TRIE_SIZE]];
211
212
213 //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes
214 mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
215 // load the rest of the data data and initialize the data members
216 reader.read(sprepBytes,mappingData);
217
218 sprepTrieImpl = new StringPrepTrieImpl();
219 sprepTrieImpl.sprepTrie = new CharTrie( new ByteArrayInputStream(sprepBytes),sprepTrieImpl );
220
221 // get the data format version
222 formatVersion = reader.getDataFormatVersion();
223
224 // get the options
225 doNFKC = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
226 checkBiDi = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
227 sprepUniVer = getVersionInfo(reader.getUnicodeVersion());
228 normCorrVer = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
229 VersionInfo normUniVer = UCharacter.getUnicodeVersion();
230 if(normUniVer.compareTo(sprepUniVer) < 0 && /* the Unicode version of SPREP file must be less than the Unicode Vesion of the normalization data */
231 normUniVer.compareTo(normCorrVer) < 0 && /* the Unicode version of the NormalizationCorrections.txt file should be less than the Unicode Vesion of the normalization data */
232 ((indexes[OPTIONS] & NORMALIZATION_ON) > 0) /* normalization turned on*/
233 ){
234 throw new IOException("Normalization Correction version not supported");
235 }
|
195 * closed after the method returns.
196 *
197 * @param inputStream The stream for reading the StringPrep profile binarySun
198 * @throws IOException
199 * @draft ICU 2.8
200 */
201 public StringPrep(InputStream inputStream) throws IOException{
202
203 BufferedInputStream b = new BufferedInputStream(inputStream,DATA_BUFFER_SIZE);
204
205 StringPrepDataReader reader = new StringPrepDataReader(b);
206
207 // read the indexes
208 indexes = reader.readIndexes(INDEX_TOP);
209
210 byte[] sprepBytes = new byte[indexes[INDEX_TRIE_SIZE]];
211
212
213 //indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes
214 mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
215 // load the rest of the data and initialize the data members
216 reader.read(sprepBytes,mappingData);
217
218 sprepTrieImpl = new StringPrepTrieImpl();
219 sprepTrieImpl.sprepTrie = new CharTrie( new ByteArrayInputStream(sprepBytes),sprepTrieImpl );
220
221 // get the data format version
222 formatVersion = reader.getDataFormatVersion();
223
224 // get the options
225 doNFKC = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
226 checkBiDi = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
227 sprepUniVer = getVersionInfo(reader.getUnicodeVersion());
228 normCorrVer = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
229 VersionInfo normUniVer = UCharacter.getUnicodeVersion();
230 if(normUniVer.compareTo(sprepUniVer) < 0 && /* the Unicode version of SPREP file must be less than the Unicode Vesion of the normalization data */
231 normUniVer.compareTo(normCorrVer) < 0 && /* the Unicode version of the NormalizationCorrections.txt file should be less than the Unicode Vesion of the normalization data */
232 ((indexes[OPTIONS] & NORMALIZATION_ON) > 0) /* normalization turned on*/
233 ){
234 throw new IOException("Normalization Correction version not supported");
235 }
|