/// <summary>
        /// Constructs the service.
        /// </summary>
        ///
        private ResourceBasedPeriodFormatterDataService()
        {
            this.lastData   = null;
            this.lastLocale = null;
            this.cache      = new Hashtable();
            IList  localeNames = new ArrayList();    // of String
            Stream mask0       = IBM.ICU.Impl.ICUData.GetRequiredStream(GetType(), PATH
                                                                        + "index.txt");

            try {
                TextReader br   = new StreamReader(mask0, System.Text.Encoding.GetEncoding("UTF-8"));
                String     str0 = null;
                while (null != (str0 = br.ReadLine()))
                {
                    str0 = str0.Trim();
                    if (str0.StartsWith("#") || str0.Length == 0)
                    {
                        continue;
                    }
                    ILOG.J2CsMapping.Collections.Generics.Collections.Add(localeNames, str0);
                }
            } catch (IOException e) {
                throw new InvalidOperationException("IO Error reading " + PATH
                                                    + "index.txt: " + e.ToString());
            }
            availableLocales = ILOG.J2CsMapping.Collections.Collections.UnmodifiableList(localeNames);
        }
        public override PeriodFormatterData Get(String localeName)
        {
            lock (this) {
                if (lastLocale != null && lastLocale.Equals(localeName))
                {
                    return(lastData);
                }

                PeriodFormatterData ld = (PeriodFormatterData)ILOG.J2CsMapping.Collections.Collections.Get(cache, localeName);
                if (ld == null)
                {
                    String ln = localeName;
                    while (!ILOG.J2CsMapping.Collections.Collections.Contains(ln, availableLocales))
                    {
                        int ix = ln.LastIndexOf("_");
                        if (ix > -1)
                        {
                            ln = ln.Substring(0, (ix) - (0));
                        }
                        else if (!"test".Equals(ln))
                        {
                            ln = "test";
                        }
                        else
                        {
                            ln = null;
                            break;
                        }
                    }
                    if (ln != null)
                    {
                        String name = PATH + "pfd_" + ln + ".xml";
                        try {
                            Stream mask0 = IBM.ICU.Impl.ICUData.GetStream(GetType(), name);
                            if (mask0 == null)
                            {
                                throw new MissingManifestResourceException("no resource named " + name);
                            }
                            else
                            {
                                DataRecord dr = IBM.ICU.Impl.Duration.Impl.DataRecord.Read(ln,
                                                                                           new XMLRecordReader(new StreamReader(mask0, System.Text.Encoding.GetEncoding("UTF-8"))));
                                if (dr != null)
                                {
                                    // debug
                                    // if (false && ln.equals("ar_EG")) {
                                    // OutputStreamWriter osw = new
                                    // OutputStreamWriter(System.out, "UTF-8");
                                    // XMLRecordWriter xrw = new
                                    // XMLRecordWriter(osw);
                                    // dr.write(xrw);
                                    // osw.flush();
                                    // }
                                    ld = new PeriodFormatterData(localeName, dr);
                                }
                            }
                        } catch (IOException e) {
                            throw new MissingManifestResourceException("Unhandled Encoding for resource " + name);
                        }
                    }
                    else
                    {
                        throw new MissingManifestResourceException("Duration data not found for  " + localeName);
                    }

                    // if (ld == null) {
                    // ld = getFallbackFormatterData();
                    // }
                    ILOG.J2CsMapping.Collections.Collections.Put(cache, localeName, ld);
                }
                lastData   = ld;
                lastLocale = localeName;

                return(ld);
            }
        }