Пример #1
0
 public virtual IIterator GetDataIterator()
 {
     // unfortunately,
     IBM.ICU.Charset.ResourceModule.Assert_is(data.GetType() == IBM.ICU.Util.UResourceBundle.ARRAY ||
                                              data.GetType() == IBM.ICU.Util.UResourceBundle.STRING);
     return(new IBM.ICU.Charset.ResourceModule.UResourceTestData.Anonymous_C0(this, data));
 }
Пример #2
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!");
                    }
                }
            }
Пример #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
            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;
            }
Пример #5
0
            internal UResourceTestData(ResourceModule module, UResourceBundle defaultHeader_0, UResourceBundle theRes)
            {
                outer_ResourceModule = module;
                IBM.ICU.Charset.ResourceModule.Assert_is(theRes != null &&
                                                         theRes.GetType() == IBM.ICU.Util.UResourceBundle.TABLE);
                res = theRes;
                // unfortunately, actually, data can be either ARRAY or STRING
                data = IBM.ICU.Charset.ResourceModule.GetFromTable(res, IBM.ICU.Charset.ResourceModule.DATA, new int[] { IBM.ICU.Util.UResourceBundle.ARRAY,
                                                                                                                         IBM.ICU.Util.UResourceBundle.STRING });

                try {
                    // unfortunately, actually, data can be either ARRAY or STRING
                    header = IBM.ICU.Charset.ResourceModule.GetFromTable(res, IBM.ICU.Charset.ResourceModule.HEADER, new int[] {
                        IBM.ICU.Util.UResourceBundle.ARRAY, IBM.ICU.Util.UResourceBundle.STRING
                    });
                } catch (MissingManifestResourceException e) {
                    if (defaultHeader_0 == null)
                    {
                        throw new TestDataModule_Constants.DataModuleFormatError(
                                  "Unable to find a header for test data '"
                                  + res.GetKey()
                                  + "' and no default header exist.");
                    }
                    else
                    {
                        header = defaultHeader_0;
                    }
                }
                try {
                    settings = IBM.ICU.Charset.ResourceModule.GetFromTable(res, IBM.ICU.Charset.ResourceModule.SETTINGS, IBM.ICU.Util.UResourceBundle.ARRAY);
                    info     = IBM.ICU.Charset.ResourceModule.GetFromTable(res, IBM.ICU.Charset.ResourceModule.INFO, IBM.ICU.Util.UResourceBundle.TABLE);
                } catch (MissingManifestResourceException e_1) {
                    // do nothing, left them null;
                    settings = data;
                }
            }
Пример #6
0
        static internal String[] GetStringArrayHelper(UResourceBundle res_0)
        {
            try {
                int type = res_0.GetType();
                switch (type)
                {
                case IBM.ICU.Util.UResourceBundle.ARRAY:
                    return(res_0.GetStringArray());

                case IBM.ICU.Util.UResourceBundle.STRING:
                    return(new String[] { res_0.GetString() });

                default:
                    throw new UResourceTypeMismatchException(
                              "Only accept ARRAY and STRING types.");
                }
            } catch (UResourceTypeMismatchException e) {
                // #if defined(FOUNDATION10) || defined(J2SE13)
                // ## throw new DataModuleFormatError(e.getMessage());
                // #else
                throw new TestDataModule_Constants.DataModuleFormatError(e);
                // #endif
            }
        }
Пример #7
0
 public virtual IIterator GetSettingsIterator()
 {
     IBM.ICU.Charset.ResourceModule.Assert_is(settings.GetType() == IBM.ICU.Util.UResourceBundle.ARRAY);
     return(new IBM.ICU.Charset.ResourceModule.UResourceTestData.Anonymous_C1(settings));
 }