KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > javacoding > jspider > api > event > JSpiderEvent


1 package net.javacoding.jspider.api.event;
2
3
4 import java.util.Date JavaDoc;
5
6
7 /**
8  * Base class of all JSpider API events. All events that will be dispatched
9  * towards JSpider modules will extends directly or indirectly from this
10  * class.
11  *
12  * $Id: JSpiderEvent.java,v 1.5 2003/03/23 15:44:48 vanrogu Exp $
13  *
14  * @author Günther Van Roey
15  */

16 public abstract class JSpiderEvent implements EventVisitable {
17
18     public static final String JavaDoc EVENT_PACKAGE = "net.javacoding.jspider.api.event.";
19
20     /** Event type used for events related to the JSpider engine. */
21     public static final int EVENT_TYPE_ENGINE = 1;
22
23     /** Event type used for events related to monitoring. */
24     public static final int EVENT_TYPE_MONITORING = 2;
25
26     /** Event type used for real spider events. */
27     public static final int EVENT_TYPE_SPIDER = 3;
28
29     /** Timestamp of the event. */
30     protected Date JavaDoc date;
31
32
33     /**
34      * Public constructor.
35      */

36     public JSpiderEvent() {
37         date = new Date JavaDoc();
38     }
39
40     /**
41      * Returns the name of the event
42      * @return name of the event
43      */

44     public String JavaDoc getName() {
45         return getClass().getName().substring(EVENT_PACKAGE.length());
46     }
47
48     /**
49      * Returns a Date object containing the event's timestamp
50      * @return Date object containing the event's timestamp
51      */

52     public Date JavaDoc getRaisedDate() {
53         return date;
54     }
55
56     /**
57      * Returns optional comments on the event.
58      * @return comment on the event.
59      */

60     public abstract String JavaDoc getComment();
61
62     /**
63      * Returns whether this event describes some sort of error situation.
64      * @return boolean that is true if this event describes an error
65      */

66     public boolean isError ( ) {
67         return false;
68     }
69
70     /**
71      * Returns whether this event can be filtered out. Only the most critical
72      * events will return FALSE.
73      * @return whether this event can be filtered out
74      */

75     public boolean isFilterable ( ) {
76         return true;
77     }
78
79     /**
80      * Returns the type of the event.
81      * @return the type of the Event - Engine / Monitoring / Spider
82      */

83     public int getType ( ) {
84       // By default, it will be a normal spider event.
85
return JSpiderEvent.EVENT_TYPE_SPIDER;
86     }
87
88     /**
89      * Accept method for the Visitor-pattern that's used for handling events.
90      * @param visitor the visitor instance that wants to visit the event
91      */

92     public void accept(EventVisitor visitor) {
93         visitor.visit(this);
94     }
95
96     /**
97      * Object's overridden toString() method.
98      * @return String representation of the event
99      */

100     public String JavaDoc toString() {
101         return this.getClass().getName();
102     }
103 }
104
Popular Tags