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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ICUNotifier.NotifyThread
The notification thread. |
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private final Object | |
| private ICUNotifier. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract boolean | acceptsListener(EventListener l)
Subclasses implement this to return true if the listener is of the appropriate type. |
| public void | |
| public void | |
| protected abstract void | |
| public void |
| listeners | back to summary |
|---|---|
| private List<EventListener> listeners | |
| notifyLock | back to summary |
|---|---|
| private final Object notifyLock | |
| notifyThread | back to summary |
|---|---|
| private ICUNotifier. | |
| ICUNotifier | back to summary |
|---|---|
| public ICUNotifier() | |
| acceptsListener | back to summary |
|---|---|
| protected abstract boolean acceptsListener(EventListener l) Subclasses implement this to return true if the listener is of the appropriate type. | |
| addListener | back to summary |
|---|---|
| public void addListener(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. | |
| notifyChanged | back to summary |
|---|---|
| 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. | |
| notifyListener | back to summary |
|---|---|
| protected abstract void notifyListener(EventListener l) Subclasses implement this to notify the listener. | |
| removeListener | back to summary |
|---|---|
| public void removeListener(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. | |
| Modifier and Type | Field and Description |
|---|---|
| private final ICUNotifier | |
| private final List |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | run()
Overrides java. Implements java. |
| notifier | back to summary |
|---|---|
| private final ICUNotifier notifier | |
| queue | back to summary |
|---|---|
| private final List<EventListener[]> queue | |
| NotifyThread | back to summary |
|---|---|
| pack-priv NotifyThread(ICUNotifier notifier) | |
| queue | back to summary |
|---|---|
| public void queue(EventListener[] list) Queue the notification on the thread. | |
| run | back to summary |
|---|---|
| public void run() Overrides java. Implements java. Wait for a notification to be queued, then notify all listeners listed in the notification.
| |