KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > webman > mainint > events > DefaultEventDistributor


1 package com.teamkonzept.webman.mainint.events;
2
3 import java.util.*;
4
5 import com.teamkonzept.web.*;
6
7 /**
8     Defaultimplementierung eines EventVerteilers, nur isHandler ist noch
9     abstrakt, verteilt die Events dynamisch und an alle, die sich interessieren
10 */

11 public abstract class DefaultEventDistributor implements TKEventHandler
12 {
13     protected Vector handlerList = new Vector();
14
15     public void handleEvent(TKEvent evt) throws com.teamkonzept.lib.TKException
16     {
17         for (int i = 0; i < handlerList.size(); i++)
18         {
19             TKEventHandler handler = (TKEventHandler)handlerList.elementAt(i);
20             if (handler.isHandler(evt))
21                 handler.handleEvent(evt);
22             if (evt.isConsumed())
23                 break;
24         }
25     }
26
27     public abstract boolean isHandler(TKEvent evt);
28
29     public void addEventHandler(TKEventHandler handler)
30     {
31         handlerList.addElement(handler);
32     }
33
34     public void removeEventHandler(TKEventHandler handler)
35     {
36         handlerList.removeElement(handler);
37     }
38
39     /** setzt die zu behandelnden Events*/
40     public void setHandleEvents(TKEvent[] events)
41     {}
42
43     /** liefert die zu behandelnden Events zurueck */
44     public TKEvent[] getHandleEvents()
45     {
46         return null;
47     }
48
49     /**
50      * Creates an event object.
51      *
52      * @param http the responsible HTTP interface.
53      * @return an event object.
54      */

55     public TKEvent createEvent (TKHttpInterface http)
56     {
57         return null;
58     }
59
60 }
61
Popular Tags