Пример #1
0
            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!");
                    }
                }
            }
Пример #2
0
        private static NumberingSystem LookupInstanceByName(string name)
        {
            int    radix;
            bool   isAlgorithmic;
            string description;

            try
            {
                UResourceBundle numberingSystemsInfo = UResourceBundle.GetBundleInstance(ICUData.IcuBaseName, "numberingSystems");
                UResourceBundle nsCurrent            = numberingSystemsInfo.Get("numberingSystems");
                UResourceBundle nsTop = nsCurrent.Get(name);

                description = nsTop.GetString("desc");
                UResourceBundle nsRadixBundle = nsTop.Get("radix");
                UResourceBundle nsAlgBundle   = nsTop.Get("algorithmic");
                radix = nsRadixBundle.GetInt32();
                int algorithmic = nsAlgBundle.GetInt32();

                isAlgorithmic = (algorithmic == 1);
            }
            catch (MissingManifestResourceException)
            {
                return(null);
            }

            return(GetInstance(name, radix, isAlgorithmic, description));
        }
Пример #3
0
        static internal UResourceBundle GetFromTable(UResourceBundle res_0, String key,
                                                     int[] expResTypes)
        {
            Assert_is(res_0 != null && key != null &&
                      res_0.GetType() == IBM.ICU.Util.UResourceBundle.TABLE);
            UResourceBundle t = res_0.Get(key);

            Assert_not(t == null);
            int type = t.GetType();

            System.Array.Sort(expResTypes);
            if (System.Array.BinarySearch(expResTypes, type) >= 0)
            {
                return(t);
            }
            else
            {
                // #if defined(FOUNDATION10) || defined(J2SE13)
                // ## throw new DataModuleFormatError("Actual type " + t.getType() +
                // " != expected types " + expResTypes + ".");
                // #else
                throw new TestDataModule_Constants.DataModuleFormatError(new UResourceTypeMismatchException(
                                                                             "Actual type " + t.GetType() + " != expected types "
                                                                             + expResTypes + "."));
                // #endif
            }
        }
Пример #4
0
        /** Reads
         *  keyInfo{
         *      deprecated{
         *                  kh{"true"}
         *                  vt{"true"}
         *      }
         *      valueType{
         *                  ca{"incremental"}
         *                  h0{"single"}
         *                  kr{"multiple"}
         *                  vt{"multiple"}
         *                  x0{"any"}
         *      }
         *  }
         */
        private static void GetKeyInfo(UResourceBundle keyInfoRes)
        {
            ISet <string> _deprecatedKeys = new HashSet <string>();
            IDictionary <string, ValueType> _valueTypes = new Dictionary <string, ValueType>(); // ICU4N NOTE: As long as we don't delete, Dictionary keeps insertion order the same as LinkedHashMap

            foreach (var keyInfoEntry in keyInfoRes)
            {
                string      key     = keyInfoEntry.Key;
                KeyInfoType keyInfo = (KeyInfoType)Enum.Parse(typeof(KeyInfoType), key, true);
                foreach (var keyInfoEntry2 in keyInfoEntry)
                {
                    string key2   = keyInfoEntry2.Key;
                    string value2 = keyInfoEntry2.GetString();
                    switch (keyInfo)
                    {
                    case KeyInfoType.deprecated:
                        _deprecatedKeys.Add(key2);
                        break;

                    case KeyInfoType.valueType:
                        _valueTypes[key2] = (ValueType)Enum.Parse(typeof(ValueType), value2, true);
                        break;
                    }
                }
            }
            DEPRECATED_KEYS = _deprecatedKeys.ToUnmodifiableSet();
            VALUE_TYPES     = _valueTypes.ToUnmodifiableDictionary();
        }
Пример #5
0
            protected override UResourceBundle HandleGet(string indexStr, IDictionary <string, string> aliasesVisited,
                                                         UResourceBundle requested)
            {
                int i = int.Parse(indexStr, CultureInfo.InvariantCulture);

                return(CreateBundleObject(i, indexStr, aliasesVisited, requested));
            }
Пример #6
0
            protected internal override UResourceBundle HandleGet(int index, Hashtable table,
                                                                  UResourceBundle requested)
            {
                if (size <= 0)
                {
                    return(null);
                }
                if (index > size)
                {
                    throw new IndexOutOfRangeException();
                }
                int offset = IBM.ICU.Impl.ICUResourceBundle.RES_GET_OFFSET(base.resource);
                // offset+0 contains number of entries
                // offset+1 contains the keyOffset
                int currentOffset = (offset) + IBM.ICU.Impl.ICUResourceBundle.GetIntOffset(1)
                                    + IBM.ICU.Impl.ICUResourceBundle.GetIntOffset(index);
                String itemKey = GetKey(currentOffset, 0);

                currentOffset += IBM.ICU.Impl.ICUResourceBundle.GetIntOffset(size);
                long resource = (IBM.ICU.Impl.ICUResourceBundle.UNSIGNED_INT_MASK)
                                & IBM.ICU.Impl.ICUResourceBundle.GetInt(rawData, currentOffset);
                String path = (isTopLevel == true) ? ILOG.J2CsMapping.Util.IlNumber.ToString(index)
                            : resPath + "/" + index;

                return(CreateBundleObject(itemKey, resource, path, table,
                                          requested, this));
            }
Пример #7
0
            protected internal override UResourceBundle HandleGet(String key, Hashtable table,
                                                                  UResourceBundle requested)
            {
                if (size <= 0)
                {
                    return(null);
                }
                int offset = IBM.ICU.Impl.ICUResourceBundle.RES_GET_OFFSET(base.resource);
                // offset+0 contains number of entries
                // offset+1 contains the keyOffset
                int currentOffset = (offset) + IBM.ICU.Impl.ICUResourceBundle.GetCharOffset(1);
                // int keyOffset = rawData.getChar(currentOffset);
                /* do a binary search for the key */
                int foundOffset = FindKey(size, currentOffset, this, key);

                if (foundOffset == -1)
                {
                    // throw new
                    // MissingResourceException(ICUResourceBundleReader.getFullName(baseName,
                    // localeID),
                    // localeID,
                    // key);
                    return(null);
                }
                currentOffset += IBM.ICU.Impl.ICUResourceBundle.GetCharOffset(size + (~size & 1))
                                 + IBM.ICU.Impl.ICUResourceBundle.GetIntOffset(foundOffset);
                long resource = (IBM.ICU.Impl.ICUResourceBundle.UNSIGNED_INT_MASK)
                                & IBM.ICU.Impl.ICUResourceBundle.GetInt(rawData, currentOffset);
                String path = (isTopLevel == true) ? key : resPath + "/" + key;

                return(CreateBundleObject(key, resource, path, table, requested,
                                          this));
            }
Пример #8
0
        /** Reads:
         *  typeInfo{
         *      deprecated{
         *                  co{
         *                      direct{"true"}
         *                  }
         *                  tz{
         *                      camtr{"true"}
         *                  }
         *      }
         *  }
         */
        private static void GetTypeInfo(UResourceBundle typeInfoRes)
        {
            IDictionary <string, ISet <string> > _deprecatedKeyTypes = new JCG.LinkedDictionary <string, ISet <string> >();

            foreach (var keyInfoEntry in typeInfoRes)
            {
                string       key      = keyInfoEntry.Key;
                TypeInfoType typeInfo = (TypeInfoType)Enum.Parse(typeof(TypeInfoType), key, true);
                foreach (var keyInfoEntry2 in keyInfoEntry)
                {
                    string        key2             = keyInfoEntry2.Key;
                    ISet <string> _deprecatedTypes = new JCG.LinkedHashSet <string>();
                    foreach (var keyInfoEntry3 in keyInfoEntry2)
                    {
                        string key3 = keyInfoEntry3.Key;
                        switch (typeInfo)
                        { // allow for expansion
                        case TypeInfoType.deprecated:
                            _deprecatedTypes.Add(key3);
                            break;
                        }
                    }
                    _deprecatedKeyTypes[key2] = _deprecatedTypes.AsReadOnly();
                }
            }
            DEPRECATED_KEY_TYPES = _deprecatedKeyTypes.AsReadOnly();
        }
Пример #9
0
        /** Reads
         *  keyInfo{
         *      deprecated{
         *                  kh{"true"}
         *                  vt{"true"}
         *      }
         *      valueType{
         *                  ca{"incremental"}
         *                  h0{"single"}
         *                  kr{"multiple"}
         *                  vt{"multiple"}
         *                  x0{"any"}
         *      }
         *  }
         */
        private static void GetKeyInfo(UResourceBundle keyInfoRes)
        {
            ISet <string> _deprecatedKeys = new JCG.HashSet <string>();
            IDictionary <string, KeyTypeDataValueType> _valueTypes = new JCG.LinkedDictionary <string, KeyTypeDataValueType>();

            foreach (var keyInfoEntry in keyInfoRes)
            {
                string      key     = keyInfoEntry.Key;
                KeyInfoType keyInfo = (KeyInfoType)Enum.Parse(typeof(KeyInfoType), key, true);
                foreach (var keyInfoEntry2 in keyInfoEntry)
                {
                    string key2   = keyInfoEntry2.Key;
                    string value2 = keyInfoEntry2.GetString();
                    switch (keyInfo)
                    {
                    case KeyInfoType.deprecated:
                        _deprecatedKeys.Add(key2);
                        break;

                    case KeyInfoType.valueType:
                        _valueTypes[key2] = (KeyTypeDataValueType)Enum.Parse(typeof(KeyTypeDataValueType), value2, true);
                        break;
                    }
                }
            }
            DEPRECATED_KEYS = _deprecatedKeys.AsReadOnly();
            VALUE_TYPES     = _valueTypes.AsReadOnly();
        }
Пример #10
0
        /** Reads:
         *  typeInfo{
         *      deprecated{
         *                  co{
         *                      direct{"true"}
         *                  }
         *                  tz{
         *                      camtr{"true"}
         *                  }
         *      }
         *  }
         */
        private static void GetTypeInfo(UResourceBundle typeInfoRes)
        {
            IDictionary <string, ISet <string> > _deprecatedKeyTypes = new Dictionary <string, ISet <string> >();  // ICU4N NOTE: As long as we don't delete, Dictionary keeps insertion order the same as LinkedHashMap

            foreach (var keyInfoEntry in typeInfoRes)
            {
                string       key      = keyInfoEntry.Key;
                TypeInfoType typeInfo = (TypeInfoType)Enum.Parse(typeof(TypeInfoType), key, true);
                foreach (var keyInfoEntry2 in keyInfoEntry)
                {
                    string        key2             = keyInfoEntry2.Key;
                    ISet <string> _deprecatedTypes = new HashSet <string>(); // ICU4N TODO: LinkedHashSet...?
                    foreach (var keyInfoEntry3 in keyInfoEntry2)
                    {
                        string key3 = keyInfoEntry3.Key;
                        switch (typeInfo)
                        { // allow for expansion
                        case TypeInfoType.deprecated:
                            _deprecatedTypes.Add(key3);
                            break;
                        }
                    }
                    _deprecatedKeyTypes[key2] = _deprecatedTypes.ToUnmodifiableSet();
                }
            }
            DEPRECATED_KEY_TYPES = _deprecatedKeyTypes.ToUnmodifiableDictionary();
        }
Пример #11
0
        /// <summary>
        /// Utility to fetch locale display data from resource bundle tables.  Convenience
        /// wrapper for <see cref="GetTableString(ICUResourceBundle, string, string, string, string)"/>.
        /// </summary>
        public static string GetTableString(string path, ULocale locale, string tableName,
                                            string itemName, string defaultValue)
        {
            ICUResourceBundle bundle = (ICUResourceBundle)UResourceBundle.
                                       GetBundleInstance(path, locale.GetBaseName());

            return(GetTableString(bundle, tableName, null, itemName, defaultValue));
        }
Пример #12
0
        /// <summary>
        /// Unfortunately, UResourceBundle is unable to treat one string as string
        /// array. This function return a String[] from UResourceBundle, regardless
        /// it is an array or a string
        /// </summary>
        ///
        static internal String[] GetStringArrayHelper(UResourceBundle res_0, String key)
        {
            UResourceBundle t = GetFromTable(res_0, key, new int[] {
                IBM.ICU.Util.UResourceBundle.ARRAY, IBM.ICU.Util.UResourceBundle.STRING
            });

            return(GetStringArrayHelper(t));
        }
        public void TestOpen()
        {
            UResourceBundle bundle = UResourceBundle.GetBundleInstance(ICUData.ICU_COLLATION_BASE_NAME, "en_US_POSIX");

            if (bundle == null)
            {
                Errln("could not load the stream");
            }
        }
Пример #14
0
        public void TestOpen()
        {
            UResourceBundle bundle = UResourceBundle.GetBundleInstance(ICUData.IcuCollationBaseName, "en_US_POSIX");

            if (bundle == null)
            {
                Errln("could not load the stream");
            }
        }
Пример #15
0
        /// <summary>
        /// Gets the rule from the rulesId. If there is no rule for this rulesId,
        /// return null.
        /// </summary>
        public virtual PluralRules GetRulesForRulesId(string rulesId)
        {
            // synchronize on the map.  release the lock temporarily while we build the rules.
            PluralRules rules = null;
            bool        hasRules; // Separate boolean because stored rules can be null.

            lock (rulesIdToRulesLock)
            {
                hasRules = rulesIdToRules.ContainsKey(rulesId);
                if (hasRules)
                {
                    rulesIdToRules.TryGetValue(rulesId, out rules);  // can be null
                }
            }
            if (!hasRules)
            {
                try
                {
                    UResourceBundle pluralb = GetPluralBundle();
                    UResourceBundle rulesb  = pluralb.Get("rules");
                    UResourceBundle setb    = rulesb.Get(rulesId);

                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < setb.Length; ++i)
                    {
                        UResourceBundle b = setb.Get(i);
                        if (i > 0)
                        {
                            sb.Append("; ");
                        }
                        sb.Append(b.Key);
                        sb.Append(": ");
                        sb.Append(b.GetString());
                    }
                    rules = PluralRules.ParseDescription(sb.ToString());
                }
                catch (FormatException)
                {
                }
                catch (MissingManifestResourceException)
                {
                }
                lock (rulesIdToRulesLock)
                {
                    if (rulesIdToRules.ContainsKey(rulesId))
                    {
                        rulesIdToRules.TryGetValue(rulesId, out rules);
                    }
                    else
                    {
                        rulesIdToRules[rulesId] = rules;  // can be null
                    }
                }
            }
            return(rules);
        }
Пример #16
0
        internal static string LoadRules(ULocale locale, string collationType)
        {
            UResourceBundle bundle = UResourceBundle.GetBundleInstance(
                ICUData.ICU_COLLATION_BASE_NAME, locale);
            UResourceBundle data = ((ICUResourceBundle)bundle).GetWithFallback(
                "collations/" + ASCII.ToLower(collationType));
            string rules = data.GetString("Sequence");

            return(rules);
        }
Пример #17
0
            private bool isStrResPrepared;     // for STRING resouce, we only
            // prepare once

            internal IteratorAdapter(UResourceBundle theRes)
            {
                this.preparedNextElement = null;
                this.isStrRes            = false;
                this.isStrResPrepared    = false;
                IBM.ICU.Charset.ResourceModule.Assert_not(theRes == null);
                res      = theRes;
                itr      = ((ICUResourceBundle)res).GetIterator();
                isStrRes = res.GetType() == IBM.ICU.Util.UResourceBundle.STRING;
            }
Пример #18
0
        internal static NumberingSystem LookupInstanceByLocale(LocaleLookupData localeLookupData)
        {
            ULocale           locale = localeLookupData.locale;
            ICUResourceBundle rb;

            try
            {
                rb = (ICUResourceBundle)UResourceBundle.GetBundleInstance(ICUData.IcuBaseName, locale);
                rb = rb.GetWithFallback("NumberElements");
            }
            catch (MissingManifestResourceException)
            {
                return(new NumberingSystem());
            }

            string numbersKeyword          = localeLookupData.numbersKeyword;
            string resolvedNumberingSystem = null;

            for (; ;)
            {
                try
                {
                    resolvedNumberingSystem = rb.GetStringWithFallback(numbersKeyword);
                    break;
                }
                catch (MissingManifestResourceException)
                { // Fall back behavior as defined in TR35
                    if (numbersKeyword.Equals("native") || numbersKeyword.Equals("finance"))
                    {
                        numbersKeyword = "default";
                    }
                    else if (numbersKeyword.Equals("traditional"))
                    {
                        numbersKeyword = "native";
                    }
                    else
                    {
                        break;
                    }
                }
            }

            NumberingSystem ns = null;

            if (resolvedNumberingSystem != null)
            {
                ns = GetInstanceByName(resolvedNumberingSystem);
            }

            if (ns == null)
            {
                ns = new NumberingSystem();
            }
            return(ns);
        }
Пример #19
0
            protected override UResourceBundle HandleGet(int index, IDictionary <string, string> aliasesVisited,
                                                         UResourceBundle requested)
            {
                string itemKey = ((ICUResourceBundleReader.Table)value).GetKey(wholeBundle.reader, index);

                if (itemKey == null)
                {
                    throw new IndexOutOfRangeException();
                }
                return(CreateBundleObject(itemKey, GetContainerResource(index), aliasesVisited, requested));
            }
Пример #20
0
            protected override UResourceBundle HandleGet(string resKey, IDictionary <string, string> aliasesVisited,
                                                         UResourceBundle requested)
            {
                int i = ((ICUResourceBundleReader.Table)value).FindTableItem(wholeBundle.reader, resKey);

                if (i < 0)
                {
                    return(null);
                }
                return(CreateBundleObject(resKey, GetContainerResource(i), aliasesVisited, requested));
            }
Пример #21
0
            protected virtual UResourceBundle CreateBundleObject(int index, string resKey, IDictionary <string, string> aliasesVisited,
                                                                 UResourceBundle requested)
            {
                int item = GetContainerResource(index);

                if (item == ResBogus)
                {
                    throw new IndexOutOfRangeException();
                }
                return(CreateBundleObject(resKey, item, aliasesVisited, requested));
            }
Пример #22
0
        internal static string LoadRules(UCultureInfo locale, string collationType)
        {
            UResourceBundle bundle = UResourceBundle.GetBundleInstance(
                // ICU4N specific - passing in the current assembly to load resources from.
                ICUData.IcuCollationBaseName, locale, ICUResourceBundle.IcuDataAssembly);
            UResourceBundle data = ((ICUResourceBundle)bundle).GetWithFallback(
                "collations/" + ASCII.ToLower(collationType));
            string rules = data.GetString("Sequence");

            return(rules);
        }
Пример #23
0
            protected internal override UResourceBundle HandleGet(String index, Hashtable table,
                                                                  UResourceBundle requested)
            {
                int val = IBM.ICU.Impl.ICUResourceBundle.GetIndex(index);

                if (val > -1)
                {
                    return(HandleGet(val, table, requested));
                }
                throw new UResourceTypeMismatchException(
                          "Could not get the correct value for index: " + index);
            }
Пример #24
0
        /// <summary>
        /// Returns a string array containing a list of the names of numbering systems
        /// currently known to ICU.
        /// </summary>
        /// <stable>ICU 4.2</stable>
        public static string[] GetAvailableNames()
        {
            UResourceBundle numberingSystemsInfo = UResourceBundle.GetBundleInstance(ICUData.IcuBaseName, "numberingSystems");
            UResourceBundle nsCurrent            = numberingSystemsInfo.Get("numberingSystems");

            var output = new List <string>();

            foreach (var rb in nsCurrent)
            {
                output.Add(rb.Key);
            }
            return(output.ToArray());
        }
Пример #25
0
            public Spec(string theSpec)
            {
                top        = theSpec;
                spec       = null;
                scriptName = null;
                try
                {
                    // Canonicalize script name.  If top is a script name then
                    // script != UScript.INVALID_CODE.
                    int script = UScript.GetCodeFromName(top);

                    // Canonicalize script name -or- do locale->script mapping
                    int[] s = UScript.GetCode(top);
                    if (s != null)
                    {
                        scriptName = UScript.GetName(s[0]);
                        // If the script name is the same as top then it's redundant
                        if (scriptName.Equals(top, StringComparison.OrdinalIgnoreCase))
                        {
                            scriptName = null;
                        }
                    }

                    isSpecLocale = false;
                    res          = null;
                    // If 'top' is not a script name, try a locale lookup
                    if (script == UScript.InvalidCode)
                    {
                        // ICU4N specific - CultureInfo doesn't support IANA culture names, so we use ULocale instead.
                        ULocale toploc = new ULocale(top);

                        //CultureInfo toploc = LocaleUtility.GetLocaleFromName(top);
                        res = (ICUResourceBundle)UResourceBundle.GetBundleInstance(ICUData.IcuTransliteratorBaseName, toploc, Transliterator.ICU_DATA_CLASS_LOADER);
                        // Make sure we got the bundle we wanted; otherwise, don't use it
                        if (res != null && LocaleUtility.IsFallbackOf(res.GetULocale().ToString(), top))
                        {
                            isSpecLocale = true;
                        }
                    }
                }
                catch (MissingManifestResourceException)
                {
                    ////CLOVER:OFF
                    // The constructor is called from multiple private methods
                    //  that protects an invalid scriptName
                    scriptName = null;
                    ////CLOVER:ON
                }
                // assert(spec != top);
                Reset();
            }
Пример #26
0
        private static string rootRules = null; // ICU4N specific - made non-volatile and used LazyInitializer

        private static void LoadRootRules()
        {
            if (rootRules != null)
            {
                return;
            }
            LazyInitializer.EnsureInitialized(ref rootRules, () =>
            {
                UResourceBundle rootBundle = UResourceBundle.GetBundleInstance(
                    // ICU4N specific - passing in the current assembly to load resources from.
                    ICUData.IcuCollationBaseName, UCultureInfo.InvariantCulture, ICUResourceBundle.IcuDataAssembly);
                return(rootBundle.GetString("UCARules"));
            });
        }
Пример #27
0
        public static DictionaryMatcher LoadDictionaryFor(string dictType)
        {
            ICUResourceBundle rb           = (ICUResourceBundle)UResourceBundle.GetBundleInstance(ICUData.IcuBreakIteratorBaseName); // com/ibm/icu/impl/data/icudt60b/brkitr
            string            dictFileName = rb.GetStringWithFallback("dictionaries/" + dictType);

            // ICU4N TODO: Possibly rename the above and use this syntax instead...?
            //var rm = new ResourceManager(ICUData.ICU_BRKITR_BASE_NAME, typeof(DictionaryData).GetTypeInfo().Assembly);
            //string dictFileName = rm.GetString("dictionaries_" + dictType);

            dictFileName = ICUData.IcuBreakIteratorName + '/' + dictFileName;
            ByteBuffer bytes = ICUBinary.GetRequiredData(dictFileName);

            ICUBinary.ReadHeader(bytes, DATA_FORMAT_ID, null);
            int[] indexes = new int[IX_COUNT];
            // TODO: read indexes[IX_STRING_TRIE_OFFSET] first, then read a variable-length indexes[]
            for (int i = 0; i < IX_COUNT; i++)
            {
                indexes[i] = bytes.GetInt32();
            }
            int offset = indexes[IX_STRING_TRIE_OFFSET];

            Assert.Assrt(offset >= (4 * IX_COUNT));
            if (offset > (4 * IX_COUNT))
            {
                int diff = offset - (4 * IX_COUNT);
                ICUBinary.SkipBytes(bytes, diff);
            }
            int trieType        = indexes[IX_TRIE_TYPE] & TRIE_TYPE_MASK;
            int totalSize       = indexes[IX_TOTAL_SIZE] - offset;
            DictionaryMatcher m = null;

            if (trieType == TRIE_TYPE_BYTES)
            {
                int    transform = indexes[IX_TRANSFORM];
                byte[] data      = new byte[totalSize];
                bytes.Get(data);
                m = new BytesDictionaryMatcher(data, transform);
            }
            else if (trieType == TRIE_TYPE_UCHARS)
            {
                Assert.Assrt(totalSize % 2 == 0);
                string data = ICUBinary.GetString(bytes, totalSize / 2, totalSize & 1);
                m = new CharsDictionaryMatcher(data);
            }
            else
            {
                m = null;
            }
            return(m);
        }
Пример #28
0
        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]);
        }
Пример #29
0
        internal ResourceModule(String baseName, String localeName)
        {
            res = (UResourceBundle)IBM.ICU.Util.UResourceBundle.GetBundleInstance(baseName,
                                                                                  localeName);
            info     = GetFromTable(res, INFO, IBM.ICU.Util.UResourceBundle.TABLE);
            testData = GetFromTable(res, TEST_DATA, IBM.ICU.Util.UResourceBundle.TABLE);

            try {
                // unfortunately, actually, data can be either ARRAY or STRING
                defaultHeader = GetFromTable(info, HEADER, new int[] {
                    IBM.ICU.Util.UResourceBundle.ARRAY, IBM.ICU.Util.UResourceBundle.STRING
                });
            } catch (MissingManifestResourceException e) {
                defaultHeader = null;
            }
        }
Пример #30
0
        /// <summary>
        /// Returns a string array containing a list of the names of numbering systems
        /// currently known to ICU.
        /// </summary>
        /// <stable>ICU 4.2</stable>
        public static string[] GetAvailableNames()
        {
            UResourceBundle numberingSystemsInfo = UResourceBundle.GetBundleInstance(ICUData.IcuBaseName, "numberingSystems");
            UResourceBundle nsCurrent            = numberingSystemsInfo.Get("numberingSystems");
            UResourceBundle temp;

            string         nsName;
            IList <string> output = new List <string>();

            foreach (var rb in nsCurrent)
            {
                temp   = rb;
                nsName = temp.Key;
                output.Add(nsName);
            }
            return(output.ToArray());
        }