01: package com.jamonapi;
02:
03: final class Listeners {
04: public static final String VALUE = "value";
05: public static final String MAX = "max";
06: public static final String MAXACTIVE = "maxactive";
07: public static final String MIN = "min";
08: private static final String[] listenerTypes = { VALUE, MAX,
09: MAXACTIVE, MIN };
10:
11: static final int VALUE_LISTENER_INDEX = 0;
12: static final int MAX_LISTENER_INDEX = 1;
13: static final int MAXACTIVE_LISTENER_INDEX = 2;
14: static final int MIN_LISTENER_INDEX = 3;
15: final ListenerType[] listenerArray = new ListenerType[4];
16:
17: Listeners(Object lockObj) {
18: for (int i = 0; i < listenerArray.length; i++)
19: listenerArray[i] = new ListenerType(lockObj);
20: }
21:
22: // return max/value/maxactive/min listener or null
23: final ListenerType getListenerType(String listenerType) {
24: for (int i = 0; i < listenerArray.length; i++)
25: if (listenerTypes[i].equalsIgnoreCase(listenerType))
26: return listenerArray[i];
27:
28: return null;
29:
30: }
31:
32: final ListenerType getListenerType(int listenerType) {
33: return listenerArray[listenerType];
34: }
35:
36: /** Returns true if any listeners exist */
37: public boolean hasListeners() {
38: for (int i = 0; i < listenerArray.length; i++) {
39: if (listenerArray[i].hasListeners())
40: return true;
41: }
42:
43: return false;
44: }
45:
46: }
|