12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */ 22ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* 32ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Copyright (C) 2008-2015, International Business Machines Corporation and 52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * others. All Rights Reserved. 62ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller ******************************************************************************* 72ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.impl; 92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.io.IOException; 112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.io.InputStream; 122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.security.AccessControlException; 132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.security.AccessController; 142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.security.PrivilegedAction; 152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.MissingResourceException; 162ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport java.util.Properties; 172ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/** 192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * ICUConfig is a class used for accessing ICU4J runtime configuration. 20836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide Only a subset of ICU is exposed in Android 212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpublic class ICUConfig { 232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static final String CONFIG_PROPS_FILE = "/android/icu/ICUConfig.properties"; 242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller private static final Properties CONFIG_PROPS; 252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller static { 272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller CONFIG_PROPS = new Properties(); 282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller try { 292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller InputStream is = ICUData.getStream(CONFIG_PROPS_FILE); 302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (is != null) { 312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller try { 322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller CONFIG_PROPS.load(is); 332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } finally { 342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller is.close(); 352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } catch (MissingResourceException mre) { 382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // If it does not exist, ignore. 392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } catch (IOException ioe) { 402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // Any IO errors, ignore 412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Get ICU configuration property value for the given name. 462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param name The configuration property name 472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @return The configuration property value, or null if it does not exist. 482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static String get(String name) { 502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return get(name, null); 512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller /** 542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * Get ICU configuration property value for the given name. 552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param name The configuration property name 562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @param def The default value 572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @return The configuration property value. If the property does not 582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * exist, <code>def</code> is returned. 592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */ 602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public static String get(String name, String def) { 612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller String val = null; 622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller final String fname = name; 632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (System.getSecurityManager() != null) { 642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller try { 652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller val = AccessController.doPrivileged(new PrivilegedAction<String>() { 662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller public String run() { 672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return System.getProperty(fname); 682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller }); 702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } catch (AccessControlException e) { 712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // ignore 722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller // TODO log this message 732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } else { 752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller val = System.getProperty(name); 762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller 782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller if (val == null) { 792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller val = CONFIG_PROPS.getProperty(name, def); 802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller return val; 822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller } 832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller} 84