KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > core > event > Event


1 /*
2  * Created on 6-sep-2005
3  * This software is OSI Certified Open Source Software.
4  * OSI Certified is a certification mark of the Open Source Initiative. The
5  * license (Mozilla version 1.0) can be read at the MMBase site. See
6  * http://www.MMBase.org/license
7  */

8 package org.mmbase.core.event;
9
10 import java.io.Serializable JavaDoc;
11
12 import org.mmbase.module.core.MMBase;
13
14 /**
15  * This class is the base class for all mmbase events
16  *
17  * @author Ernst Bunders
18  * @since MMBase-1.8
19  * @version $Id: Event.java,v 1.8 2006/07/06 09:52:30 michiel Exp $
20  */

21 public abstract class Event implements Serializable JavaDoc, org.mmbase.util.PublicCloneable {
22
23
24     public static final int TYPE_UNSPECIFIED = -1;
25     public static final int TYPE_NEW = 0;
26     public static final int TYPE_CHANGE = 1;
27     public static final int TYPE_DELETE = 2;
28
29     protected int eventType = TYPE_UNSPECIFIED;
30     protected String JavaDoc machine;
31
32     /**
33      * Every event originates from a certain machine, which is identified by a String.
34      * If this equals {@link MMBase#getMachineName()} then this is a local event.
35      */

36     public String JavaDoc getMachine() {
37         return machine;
38     }
39     public boolean isLocal() {
40         return MMBase.getMMBase().getMachineName().equals(machine);
41     }
42
43
44     /**
45      * Most events will come in certain 'types', default contants which are provided are {@link
46      * #TYPE_NEW}, {@link #TYPE_CHANGE} and {@link #TYPE_DELETE}.
47      */

48     public int getType() {
49         return eventType;
50     }
51
52     /**
53      * @param machine The machine name. If <code>null</code> the local machine name is extracted from MMBase, using
54      * {@link MMBase#getMachineName()}
55      */

56     public Event(String JavaDoc machine, int type) {
57         this.machine = machine == null ?
58             MMBase.getMMBase().getMachineName() :
59             machine;
60         this.eventType = type;
61     }
62
63     public Event(String JavaDoc machine) {
64         this(machine, TYPE_UNSPECIFIED);
65     }
66
67     public Object JavaDoc clone(){
68         Object JavaDoc clone = null;
69         try {
70             clone = super.clone();
71         } catch (CloneNotSupportedException JavaDoc e) {}
72         return clone;
73     }
74
75 }
76
Popular Tags