01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.net.util;
17:
18: import java.io.Serializable;
19: import java.util.Enumeration;
20: import java.util.EventListener;
21: import java.util.Vector;
22:
23: /**
24: * @author Daniel F. Savarese
25: */
26:
27: public class ListenerList implements Serializable {
28: private Vector __listeners;
29:
30: public ListenerList() {
31: __listeners = new Vector();
32: }
33:
34: public synchronized void addListener(EventListener listener) {
35: __listeners.addElement(listener);
36: }
37:
38: public synchronized void removeListener(EventListener listener) {
39: __listeners.removeElement(listener);
40: }
41:
42: public synchronized Enumeration getListeners() {
43: return ((Vector) __listeners.clone()).elements();
44: }
45:
46: public int getListenerCount() {
47: return __listeners.size();
48: }
49:
50: }
|