/// <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); }
/// <summary> /// Clear caches maintained by this service. Subclasses can override if they /// implement additional that need to be cleared when the service changes. /// Subclasses should generally not call this method directly, as it must /// only be called while synchronized on this. /// </summary> /// protected internal void ClearCaches() { // we don't synchronize on these because methods that use them // copy before use, and check for changes if they modify the // caches. cacheref = null; idref = null; dnref = null; }