/* try the cache first */
String[][] data = cachedLocaleData.get(locale);
String[] numberElements;
if (data == null) { /* cache miss */
data = new String[1][];
ICUResourceBundle rb = (ICUResourceBundle)UResourceBundle.
getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
boolean isLatn = nsName.equals("latn");
String baseKey = "NumberElements/" + nsName + "/symbols/";
String latnKey = "NumberElements/latn/symbols/";
String[] symbolKeys = { "decimal", "group", "list", "percentSign", "minusSign", "plusSign", "exponential", "perMille", "infinity", "nan", "currencyDecimal", "currencyGroup" };
String[] fallbackElements = { ".", ",", ";", "%", "-", "+", "E", "\u2030", "\u221e", "NaN", null, null };
String[] symbolsArray = new String[symbolKeys.length];
for ( int i = 0 ; i < symbolKeys.length; i++ ) {
try {
symbolsArray[i] = rb.getStringWithFallback(baseKey+symbolKeys[i]);
} catch (MissingResourceException ex) {
if (!isLatn) { // Fall back to latn numbering system for symbols if desired symbol isn't found.
try {
symbolsArray[i] = rb.getStringWithFallback(latnKey+symbolKeys[i]);
} catch (MissingResourceException ex1) {
symbolsArray[i] = fallbackElements[i];
}
} else {
symbolsArray[i] = fallbackElements[i];
}
}
}
data[0] = symbolsArray;
/* update cache */
cachedLocaleData.put(locale, data);
}
numberElements = data[0];
ICUResourceBundle r = (ICUResourceBundle)UResourceBundle.
getBundleInstance(ICUResourceBundle.ICU_BASE_NAME, locale);
// TODO: Determine actual and valid locale correctly.
ULocale uloc = r.getULocale();
setLocale(uloc, uloc);
decimalSeparator = numberElements[0].charAt(0);
groupingSeparator = numberElements[1].charAt(0);