Exemple #1
0
 /// <summary>
 /// Stop notifying this listener. The listener must not be null. Attemps to
 /// remove a listener that is not registered will be silently ignored.
 /// </summary>
 ///
 public void RemoveListener(IEventListener l)
 {
     if (l == null)
     {
         throw new NullReferenceException();
     }
     lock (notifyLock) {
         if (listeners != null)
         {
             // identity equality check
             IIterator iter = new ILOG.J2CsMapping.Collections.IteratorAdapter(listeners.GetEnumerator());
             while (iter.HasNext())
             {
                 if (iter.Next() == (Object)l)
                 {
                     iter.Remove();
                     if (listeners.Count == 0)
                     {
                         listeners = null;
                     }
                     return;
                 }
             }
         }
     }
 }
Exemple #2
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);
        }
 public static ICollection RetainAll(ICollection c, CollectionUtilities.ObjectMatcher f)
 {
     for (IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(c.GetEnumerator()); it.HasNext();)
     {
         Object item = it.Next();
         if (!f.Matches(item))
         {
             it.Remove();
         }
     }
     return(c);
 }