|
org.netbeans.modules.editor.util/1 1.26 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.lib.editor.util.PriorityListenerList<T>
public class PriorityListenerList<T extends EventListener>
Listener list that layers the maintained listeners
according to the given priority index.
Simply said it's an array of listener arrays. The priority index defines
the event listeners array holding all the listeners with the given priority index.
| Constructor Summary | |
|---|---|
PriorityListenerList()
|
|
| Method Summary | |
|---|---|
void |
add(T listener,
int priority)
Add listener with the given priority. |
int |
getListenerCount()
Get total count of listeners contained in this list at all priority levels. |
T[][] |
getListenersArray()
Return the actual array of listeners arrays maintained by this listeners list. |
void |
remove(T listener,
int priority)
Remove listener with the given priority index. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PriorityListenerList()
| Method Detail |
|---|
public void add(T listener,
int priority)
listener - listener to be added. If null is passed it is ignored (nothing gets added).priority - >=0 index defining priority
with which the listener should be fired.
IndexOutOfBoundsException - when priority < 0
public void remove(T listener,
int priority)
listener - listener to be removed. If null is passed it is ignored (nothing gets removed).priority - >=0 index defining priority
with which the listener was originally added.
IndexOutOfBoundsException - when priority < 0public T[][] getListenersArray()
The higher index means sooner firing. Listeners with the same priority are ordered so that the one added sooner has higher index than the one added later. So the following firing mechanism should be used:
private void fireMyEvent(MyEvent evt) {
MyListener[][] listenersArray = priorityListenerList.getListenersArray();
for (int priority = listenersArray.length - 1; priority >= 0; priority--) {
MyListener[] listeners = listenersArray[priority];
for (int i = listeners.length - 1; i >= 0; i--) {
listeners[i].notify(evt);
}
}
}
public int getListenerCount()
|
org.netbeans.modules.editor.util/1 1.26 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||