1 /* GENERATED SOURCE. DO NOT MODIFY. */ 2 // © 2016 and later: Unicode, Inc. and others. 3 // License & terms of use: http://www.unicode.org/copyright.html#License 4 /* 5 ******************************************************************************* 6 * Copyright (C) 2012-2014, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 ******************************************************************************* 9 * CollationRoot.java, ported from collationroot.h/.cpp 10 * 11 * C++ version created on: 2012dec17 12 * created by: Markus W. Scherer 13 */ 14 15 package ohos.global.icu.impl.coll; 16 17 import java.io.IOException; 18 import java.nio.ByteBuffer; 19 import java.util.MissingResourceException; 20 21 import ohos.global.icu.impl.ICUBinary; 22 import ohos.global.icu.impl.ICUData; 23 24 /** 25 * Collation root provider. 26 * @hide exposed on OHOS 27 */ 28 public final class CollationRoot { // purely static 29 private static final CollationTailoring rootSingleton; 30 private static final RuntimeException exception; 31 getRoot()32 public static final CollationTailoring getRoot() { 33 if(exception != null) { 34 throw exception; 35 } 36 return rootSingleton; 37 } getData()38 public static final CollationData getData() { 39 CollationTailoring root = getRoot(); 40 return root.data; 41 } getSettings()42 static final CollationSettings getSettings() { 43 CollationTailoring root = getRoot(); 44 return root.settings.readOnly(); 45 } 46 47 static { // Corresponds to C++ load() function. 48 CollationTailoring t = null; 49 RuntimeException e2 = null; 50 try { 51 ByteBuffer bytes = ICUBinary.getRequiredData("coll/ucadata.icu"); 52 CollationTailoring t2 = new CollationTailoring(null); CollationDataReader.read(null, bytes, t2)53 CollationDataReader.read(null, bytes, t2); 54 // Keep t=null until after the root data has been read completely. 55 // Otherwise we would set a non-null root object if the data reader throws an exception. 56 t = t2; 57 } catch(IOException e) { 58 e2 = new MissingResourceException( 59 "IOException while reading CLDR root data", 60 "CollationRoot", ICUData.ICU_BUNDLE + "/coll/ucadata.icu"); 61 } catch(RuntimeException e) { 62 e2 = e; 63 } 64 rootSingleton = t; 65 exception = e2; 66 } 67 } 68