示例#1
0
        /// <summary>
        /// Return a snapshot of the mapping from display names to visible IDs for
        /// this service. This set will not change as factories are added or removed,
        /// but the supported ids will, so there is no guarantee that all and only
        /// the ids in the returned map will be visible and supported by the service
        /// in subsequent calls, nor is there any guarantee that the current display
        /// names match those in the set. The display names are sorted based on the
        /// comparator provided.
        /// </summary>
        ///
        public SortedList GetDisplayNames(ULocale locale, IComparer com,
                                          String matchID)
        {
            SortedList dncache = null;

            ICUService.LocaleRef xref = dnref;

            if (xref != null)
            {
                dncache = xref.Get(locale, com);
            }

            while (dncache == null)
            {
                lock (this) {
                    if (xref == dnref || dnref == null)
                    {
                        dncache = new SortedList(com);                 // sorted

                        IDictionary m  = GetVisibleIDMap();
                        IIterator   ei = new ILOG.J2CsMapping.Collections.IteratorAdapter(m.GetEnumerator());
                        while (ei.HasNext())
                        {
                            DictionaryEntry    e    = (DictionaryEntry)ei.Next();
                            String             id_0 = (String)((DictionaryEntry)e).Key;
                            ICUService.Factory f    = (ICUService.Factory)((DictionaryEntry)e).Value;
                            ILOG.J2CsMapping.Collections.Collections.Put(dncache, f.GetDisplayName(id_0, locale), id_0);
                        }

                        dncache = /*ILOG.J2CsMapping.Collections.Generics.Collections.UnmodifiableSortedMap(*/ dncache /*)*/;
                        dnref   = new ICUService.LocaleRef(dncache, locale, com);
                    }
                    else
                    {
                        xref    = dnref;
                        dncache = xref.Get(locale, com);
                    }
                }
            }

            ICUService.Key matchKey = CreateKey(matchID);
            if (matchKey == null)
            {
                return(dncache);
            }

            SortedList result = new SortedList(dncache);
            IIterator  iter   = new ILOG.J2CsMapping.Collections.IteratorAdapter(result.GetEnumerator());

            while (iter.HasNext())
            {
                DictionaryEntry e_1 = (DictionaryEntry)iter.Next();
                if (!matchKey.IsFallbackOf((String)((DictionaryEntry)e_1).Value))
                {
                    iter.Remove();
                }
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// <p>
        /// Return a snapshot of the visible IDs for this service. This set will not
        /// change as Factories are added or removed, but the supported ids will, so
        /// there is no guarantee that all and only the ids in the returned set are
        /// visible and supported by the service in subsequent calls.
        /// </p>
        /// <p>
        /// matchID is passed to createKey to create a key. If the key is not null,
        /// it is used to filter out ids that don't have the key as a fallback.
        /// </summary>
        ///
        public ILOG.J2CsMapping.Collections.ISet GetVisibleIDs(String matchID)
        {
            ILOG.J2CsMapping.Collections.ISet result = new ILOG.J2CsMapping.Collections.ListSet(GetVisibleIDMap().Keys);

            ICUService.Key fallbackKey = CreateKey(matchID);

            if (fallbackKey != null)
            {
                ILOG.J2CsMapping.Collections.ISet temp = new HashedSet(result.Count);
                IIterator iter = new ILOG.J2CsMapping.Collections.IteratorAdapter(result.GetEnumerator());
                while (iter.HasNext())
                {
                    String id_0 = (String)iter.Next();
                    if (fallbackKey.IsFallbackOf(id_0))
                    {
                        ILOG.J2CsMapping.Collections.Generics.Collections.Add(temp, id_0);
                    }
                }
                result = temp;
            }
            return(result);
        }