OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************* | 2 ******************************************************************************* |
3 * Copyright (C) 2009-2014, International Business Machines | 3 * Copyright (C) 2009-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************* | 5 ******************************************************************************* |
6 */ | 6 */ |
7 | 7 |
8 package com.ibm.icu.impl; | 8 package com.ibm.icu.impl; |
9 | 9 |
10 import java.io.IOException; | 10 import java.io.IOException; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 return singleton.allModes; | 338 return singleton.allModes; |
339 } | 339 } |
340 } | 340 } |
341 return cache.getInstance(name, bytes); | 341 return cache.getInstance(name, bytes); |
342 } | 342 } |
343 private static CacheBase<String, Norm2AllModes, ByteBuffer> cache = | 343 private static CacheBase<String, Norm2AllModes, ByteBuffer> cache = |
344 new SoftCache<String, Norm2AllModes, ByteBuffer>() { | 344 new SoftCache<String, Norm2AllModes, ByteBuffer>() { |
345 protected Norm2AllModes createInstance(String key, ByteBuffer bytes)
{ | 345 protected Norm2AllModes createInstance(String key, ByteBuffer bytes)
{ |
346 Normalizer2Impl impl; | 346 Normalizer2Impl impl; |
347 if(bytes==null) { | 347 if(bytes==null) { |
348 impl=new Normalizer2Impl().load(ICUResourceBundle.ICU_BUNDLE
+"/"+key+".nrm"); | 348 impl=new Normalizer2Impl().load(key+".nrm"); |
349 } else { | 349 } else { |
350 impl=new Normalizer2Impl().load(bytes); | 350 impl=new Normalizer2Impl().load(bytes); |
351 } | 351 } |
352 return new Norm2AllModes(impl); | 352 return new Norm2AllModes(impl); |
353 } | 353 } |
354 }; | 354 }; |
355 | 355 |
356 public static final NoopNormalizer2 NOOP_NORMALIZER2=new NoopNormalizer2(); | 356 public static final NoopNormalizer2 NOOP_NORMALIZER2=new NoopNormalizer2(); |
357 /** | 357 /** |
358 * Gets the FCD normalizer, with the FCD data initialized. | 358 * Gets the FCD normalizer, with the FCD data initialized. |
359 * @return FCD normalizer | 359 * @return FCD normalizer |
360 */ | 360 */ |
361 public static Normalizer2 getFCDNormalizer2() { | 361 public static Normalizer2 getFCDNormalizer2() { |
362 return getNFCInstance().fcd; | 362 return getNFCInstance().fcd; |
363 } | 363 } |
364 | 364 |
365 private static final class Norm2AllModesSingleton { | 365 private static final class Norm2AllModesSingleton { |
366 private Norm2AllModesSingleton(String name) { | 366 private Norm2AllModesSingleton(String name) { |
367 try { | 367 try { |
368 Normalizer2Impl impl=new Normalizer2Impl().load( | 368 Normalizer2Impl impl=new Normalizer2Impl().load(name+".nrm"); |
369 ICUResourceBundle.ICU_BUNDLE+"/"+name+".nrm"); | |
370 allModes=new Norm2AllModes(impl); | 369 allModes=new Norm2AllModes(impl); |
371 } catch(RuntimeException e) { | 370 } catch(RuntimeException e) { |
372 exception=e; | 371 exception=e; |
373 } | 372 } |
374 } | 373 } |
375 | 374 |
376 private Norm2AllModes allModes; | 375 private Norm2AllModes allModes; |
377 private RuntimeException exception; | 376 private RuntimeException exception; |
378 } | 377 } |
379 private static final class NFCSingleton { | 378 private static final class NFCSingleton { |
380 private static final Norm2AllModesSingleton INSTANCE=new Norm2AllModesSi
ngleton("nfc"); | 379 private static final Norm2AllModesSingleton INSTANCE=new Norm2AllModesSi
ngleton("nfc"); |
381 } | 380 } |
382 private static final class NFKCSingleton { | 381 private static final class NFKCSingleton { |
383 private static final Norm2AllModesSingleton INSTANCE=new Norm2AllModesSi
ngleton("nfkc"); | 382 private static final Norm2AllModesSingleton INSTANCE=new Norm2AllModesSi
ngleton("nfkc"); |
384 } | 383 } |
385 private static final class NFKC_CFSingleton { | 384 private static final class NFKC_CFSingleton { |
386 private static final Norm2AllModesSingleton INSTANCE=new Norm2AllModesSi
ngleton("nfkc_cf"); | 385 private static final Norm2AllModesSingleton INSTANCE=new Norm2AllModesSi
ngleton("nfkc_cf"); |
387 } | 386 } |
388 } | 387 } |
OLD | NEW |