internal String GetZoneString(ULocale locale, String olsonID, int item) { IDictionary data = (IDictionary)ILOG.J2CsMapping.Collections.Collections.Get(zoneData, locale); if (data == null) { data = new Hashtable(); if (SHOW_ALL) { System.Console.Out.WriteLine(); } if (SHOW_ALL) { System.Console.Out.WriteLine("zones for " + locale); } ICUResourceBundle bundle = (ICUResourceBundle)IBM.ICU.Util.UResourceBundle .GetBundleInstance(locale); ICUResourceBundle table = bundle.GetWithFallback("zoneStrings"); for (int i = 0; i < table.GetSize(); ++i) { UResourceBundle stringSet = table.Get(i); // ICUResourceBundle stringSet = // table.getWithFallback(String.valueOf(i)); String key = stringSet.GetString(0); if (SHOW_ALL) { System.Console.Out.WriteLine("key: " + key); } ArrayList list = new ArrayList(); for (int j = 1; j < stringSet.GetSize(); ++j) { String entry = stringSet.GetString(j); if (SHOW_ALL) { System.Console.Out.WriteLine(" entry: " + entry); } ILOG.J2CsMapping.Collections.Generics.Collections.Add(list, entry); } ILOG.J2CsMapping.Collections.Collections.Put(data, key, ILOG.J2CsMapping.Collections.Generics.Collections.ToArray(list, new String[list.Count])); } ILOG.J2CsMapping.Collections.Collections.Put(zoneData, locale, data); } String[] strings = (String[])ILOG.J2CsMapping.Collections.Collections.Get(data, olsonID); if (strings == null || item >= strings.Length) { return(olsonID); } return(strings[item]); }
/// <summary> /// Initializes the symbols from the LocaleElements resource bundle. Note: /// The organization of LocaleElements badly needs to be cleaned up. /// </summary> /// private void Initialize(ULocale locale) { this.requestedLocale = locale.ToLocale(); this.ulocale = locale; /* try the cache first */ String[][] data = (String[][])cachedLocaleData[locale]; String[] numberElements; if (data == null) /* cache miss */ { data = new String[1][]; ICUResourceBundle rb = (ICUResourceBundle)IBM.ICU.Util.UResourceBundle .GetBundleInstance(IBM.ICU.Impl.ICUResourceBundle.ICU_BASE_NAME, locale); data[0] = rb.GetStringArray("NumberElements"); /* update cache */ ILOG.J2CsMapping.Collections.Collections.Put(cachedLocaleData, locale, data); } numberElements = data[0]; ICUResourceBundle r = (ICUResourceBundle)IBM.ICU.Util.UResourceBundle .GetBundleInstance(IBM.ICU.Impl.ICUResourceBundle.ICU_BASE_NAME, locale); // TODO: Determine actual and valid locale correctly. ULocale uloc = r.GetULocale(); SetLocale(uloc, uloc); // {dlf} clean up below now that we have our own resource data decimalSeparator = numberElements[0][0]; groupingSeparator = numberElements[1][0]; // Temporary hack to support old JDK 1.1 resources // patternSeparator = numberElements[2].length() > 0 ? // numberElements[2].charAt(0) : ';'; patternSeparator = numberElements[2][0]; percent = numberElements[3][0]; zeroDigit = numberElements[4][0]; // different for Arabic,etc. digit = numberElements[5][0]; minusSign = numberElements[6][0]; // Temporary hack to support JDK versions before 1.1.6 (?) // exponentSeparator = numberElements.length >= 9 ? // numberElements[7] : DecimalFormat.PATTERN_EXPONENT; // perMill = numberElements.length >= 9 ? // numberElements[8].charAt(0) : '\u2030'; // infinity = numberElements.length >= 10 ? // numberElements[9] : "\u221e"; // NaN = numberElements.length >= 11 ? // numberElements[10] : "\ufffd"; exponentSeparator = numberElements[7]; perMill = numberElements[8][0]; infinity = numberElements[9]; NaN = numberElements[10]; plusSign = numberElements[11][0]; padEscape = IBM.ICU.Text.DecimalFormat.PATTERN_PAD_ESCAPE; sigDigit = IBM.ICU.Text.DecimalFormat.PATTERN_SIGNIFICANT_DIGIT; // Obtain currency data from the currency API. This is strictly // for backward compatibility; we don't use DecimalFormatSymbols // for currency data anymore. String currname = null; currency = IBM.ICU.Util.Currency.GetInstance(locale); if (currency != null) { intlCurrencySymbol = currency.GetCurrencyCode(); bool[] isChoiceFormat = new bool[1]; currname = currency.GetName(locale, IBM.ICU.Util.Currency.SYMBOL_NAME, isChoiceFormat); // If this is a ChoiceFormat currency, then format an // arbitrary value; pick something != 1; more common. currencySymbol = (isChoiceFormat[0]) ? new ChoiceFormat(currname) .Format(2.0d) : currname; } else { intlCurrencySymbol = "XXX"; currencySymbol = "\u00A4"; // 'OX' currency symbol } // If there is a currency decimal, use it. monetarySeparator = decimalSeparator; monetaryGroupingSeparator = groupingSeparator; Currency curr = IBM.ICU.Util.Currency.GetInstance(locale); if (curr != null) { String currencyCode = curr.GetCurrencyCode(); if (currencyCode != null) { /* An explicit currency was requested */ ICUResourceBundle resource = (ICUResourceBundle)IBM.ICU.Util.UResourceBundle .GetBundleInstance(IBM.ICU.Impl.ICUResourceBundle.ICU_BASE_NAME, locale); ICUResourceBundle currencyRes = resource .GetWithFallback("Currencies"); try { currencyRes = currencyRes.GetWithFallback(currencyCode); if (currencyRes.GetSize() > 2) { currencyRes = (ICUResourceBundle)currencyRes.Get(2); currencyPattern = currencyRes.GetString(0); monetarySeparator = currencyRes.GetString(1)[0]; monetaryGroupingSeparator = currencyRes.GetString(2)[0]; } } catch (MissingManifestResourceException ex) { /* * else An explicit currency was requested and is unknown or * locale data is malformed. */ /* decimal format API will get the correct value later on. */ } } /* else no currency keyword used. */ } // monetarySeparator = numberElements[11].charAt(0); }