internal UArrayResource(UResourceBundle theHeader, UResourceBundle theData) { IBM.ICU.Charset.ResourceModule.Assert_is(theHeader != null && theData != null); String[] header_0; header_0 = IBM.ICU.Charset.ResourceModule.GetStringArrayHelper(theHeader); if (theData.GetSize() != header_0.Length) { throw new TestDataModule_Constants.DataModuleFormatError( "The count of Header and Data is mismatch."); } theMap = new Hashtable(); for (int i = 0; i < header_0.Length; i++) { if (theData.GetType() == IBM.ICU.Util.UResourceBundle.ARRAY) { ILOG.J2CsMapping.Collections.Collections.Put(theMap, header_0[i], theData.Get(i)); } else if (theData.GetType() == IBM.ICU.Util.UResourceBundle.STRING) { ILOG.J2CsMapping.Collections.Collections.Put(theMap, header_0[i], theData.GetString()); } else { throw new TestDataModule_Constants.DataModuleFormatError( "Did not get the expected data!"); } } }
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]); }
// private static final String INVALID_NAME = "Invalid"; /// <summary> /// Helper function to find the code from locale. /// </summary> /// /// <param name="locale">The locale.</param> private static int[] FindCodeFromLocale(ULocale locale) { ICUResourceBundle rb; try { rb = (ICUResourceBundle)IBM.ICU.Util.UResourceBundle.GetBundleInstance( IBM.ICU.Impl.ICUResourceBundle.ICU_BASE_NAME, locale); } catch (MissingManifestResourceException e) { return(null); } // if rb is not a strict fallback of the requested locale, return null // if(!LocaleUtility.isFallbackOf(rb.getULocale().toString(), // locale.toString())){ // return null; // } // non existent locale check if (rb.GetLoadingStatus() == IBM.ICU.Impl.ICUResourceBundle.FROM_DEFAULT && !locale.Equals(IBM.ICU.Util.ULocale.GetDefault())) { return(null); } UResourceBundle sub = rb.Get(kLocaleScript); int[] result = new int[sub.GetSize()]; int w = 0; for (int i = 0; i < result.Length; ++i) { int code = IBM.ICU.Lang.UCharacter.GetPropertyValueEnum(IBM.ICU.Lang.UProperty_Constants.SCRIPT, sub.GetString(i)); result[w++] = code; } if (w < result.Length) { throw new InvalidOperationException("bad locale data, listed " + result.Length + " scripts but found only " + w); } return(result); }