Class ICUNotifier

  • Direct Known Subclasses:
    ICUService

    public abstract class ICUNotifier
    extends java.lang.Object

    Abstract implementation of a notification facility. Clients add EventListeners with addListener and remove them with removeListener. Notifiers call notifyChanged when they wish to notify listeners. This queues the listener list on the notification thread, which eventually dequeues the list and calls notifyListener on each listener in the list.

    Subclasses override acceptsListener and notifyListener to add type-safe notification. AcceptsListener should return true if the listener is of the appropriate type; ICUNotifier itself will ensure the listener is non-null and that the identical listener is not already registered with the Notifier. NotifyListener should cast the listener to the appropriate type and call the appropriate method on the listener.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  ICUNotifier.NotifyThread
      The notification thread.
    • Constructor Summary

      Constructors 
      Constructor Description
      ICUNotifier()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract boolean acceptsListener​(java.util.EventListener l)
      Subclasses implement this to return true if the listener is of the appropriate type.
      void addListener​(java.util.EventListener l)
      Add a listener to be notified when notifyChanged is called.
      void notifyChanged()
      Queue a notification on the notification thread for the current listeners.
      protected abstract void notifyListener​(java.util.EventListener l)
      Subclasses implement this to notify the listener.
      void removeListener​(java.util.EventListener l)
      Stop notifying this listener.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • notifyLock

        private final java.lang.Object notifyLock
      • listeners

        private java.util.List<java.util.EventListener> listeners
    • Constructor Detail

      • ICUNotifier

        public ICUNotifier()
    • Method Detail

      • addListener

        public void addListener​(java.util.EventListener l)
        Add a listener to be notified when notifyChanged is called. The listener must not be null. AcceptsListener must return true for the listener. Attempts to concurrently register the identical listener more than once will be silently ignored.
      • removeListener

        public void removeListener​(java.util.EventListener l)
        Stop notifying this listener. The listener must not be null. Attempts to remove a listener that is not registered will be silently ignored.
      • notifyChanged

        public void notifyChanged()
        Queue a notification on the notification thread for the current listeners. When the thread unqueues the notification, notifyListener is called on each listener from the notification thread.
      • acceptsListener

        protected abstract boolean acceptsListener​(java.util.EventListener l)
        Subclasses implement this to return true if the listener is of the appropriate type.
      • notifyListener

        protected abstract void notifyListener​(java.util.EventListener l)
        Subclasses implement this to notify the listener.