KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > net > util > ListenerList


1 /*
2  * Copyright 2001-2005 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.util.Enumeration JavaDoc;
20 import java.util.EventListener JavaDoc;
21 import java.util.Vector JavaDoc;
22
23 /**
24  * @author Daniel F. Savarese
25  */

26
27 public class ListenerList implements Serializable JavaDoc
28 {
29     private Vector JavaDoc __listeners;
30
31     public ListenerList()
32     {
33         __listeners = new Vector JavaDoc();
34     }
35
36     public synchronized void addListener(EventListener JavaDoc listener)
37     {
38         __listeners.addElement(listener);
39     }
40
41     public synchronized void removeListener(EventListener JavaDoc listener)
42     {
43         __listeners.removeElement(listener);
44     }
45
46     public synchronized Enumeration JavaDoc getListeners()
47     {
48         return ((Vector JavaDoc)__listeners.clone()).elements();
49     }
50
51     public int getListenerCount()
52     {
53         return __listeners.size();
54     }
55
56 }
57
Popular Tags