Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public abstract Class ICUNotifier

extends Object
Class Inheritance
Known Direct Subclasses
com.ibm.icu.impl.ICUService
Imports
java.util.ArrayList, .EventListener, .Iterator, .List

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
ICUNotifier.NotifyThread

The notification thread.

Field Summary

Modifier and TypeField and Description
private List<EventListener>
private final Object
private ICUNotifier.NotifyThread

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract boolean
acceptsListener(EventListener l)

Subclasses implement this to return true if the listener is of the appropriate type.

public void
addListener(EventListener l)

Add a listener to be notified when notifyChanged is called.

public void
notifyChanged()

Queue a notification on the notification thread for the current listeners.

protected abstract void
notifyListener(EventListener l)

Subclasses implement this to notify the listener.

public void
removeListener(EventListener l)

Stop notifying this listener.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listenersback to summary
private List<EventListener> listeners
notifyLockback to summary
private final Object notifyLock
notifyThreadback to summary
private ICUNotifier.NotifyThread notifyThread

Constructor Detail

ICUNotifierback to summary
public ICUNotifier()

Method Detail

acceptsListenerback to summary
protected abstract boolean acceptsListener(EventListener l)

Subclasses implement this to return true if the listener is of the appropriate type.

addListenerback 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.

notifyChangedback 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.

notifyListenerback to summary
protected abstract void notifyListener(EventListener l)

Subclasses implement this to notify the listener.

removeListenerback 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.

com.ibm.icu.impl back to summary

private Class ICUNotifier.NotifyThread

extends Thread
Class Inheritance

The notification thread.

Field Summary

Modifier and TypeField and Description
private final ICUNotifier
private final List<EventListener[]>
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
queue(EventListener[] list)

Queue the notification on the thread.

public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Wait for a notification to be queued, then notify all listeners listed in the notification.
Inherited from java.lang.Thread:
activeCountcheckAccessclonecountStackFramescurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitresumesetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopsuspendthreadIdtoStringyield

Field Detail

notifierback to summary
private final ICUNotifier notifier
queueback to summary
private final List<EventListener[]> queue

Constructor Detail

NotifyThreadback to summary
pack-priv NotifyThread(ICUNotifier notifier)

Method Detail

queueback to summary
public void queue(EventListener[] list)

Queue the notification on the thread.

runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Wait for a notification to be queued, then notify all listeners listed in the notification.

Annotations
@Override