KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > syncclient > spds > event > SyncEvent


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package sync4j.syncclient.spds.event;
20
21 import java.util.Date JavaDoc;
22
23 /**
24  * Is used to notify the listeners
25  * for the principal states.
26  *
27  * @author Fabio Maggi
28  *
29  * @version $Id: SyncEvent.java,v 1.2 2005/01/19 11:18:36 fabius Exp $
30  */

31 public class SyncEvent {
32
33     // -------------------------------------------------------- Constants
34

35     /** The synchronization process start */
36     public static final int SYNC_BEGIN = 0 ;
37
38     /** The synchronization process end */
39     public static final int SYNC_END = 1 ;
40
41     /** A no blocking error occours */
42     public static final int SYNC_ERROR = 2 ;
43
44     /** Send initialization message */
45     public static final int SEND_INITIALIZATION = 3 ;
46
47     /** Send modification message */
48     public static final int SEND_MODIFICATION = 4 ;
49
50     /** Send finalization message */
51     public static final int SEND_FINALIZATION = 5 ;
52
53     // -------------------------------------------------------- Private data
54

55     private Throwable JavaDoc cause = null ;
56     private Date JavaDoc date = null ;
57     private String JavaDoc message = null ;
58     private int type = 0 ;
59
60     // -------------------------------------------------------- Constructors
61

62     /**
63      * Creates a SyncEvent
64      *
65      * @param type the event type
66      * @param date the date and time when the event occours
67      */

68     public SyncEvent (int type, long date) {
69
70         this.type = type;
71         this.date = new Date JavaDoc(date);
72
73     }
74
75     /**
76      * Creates a SyncEvent
77      *
78      * @param type the event type
79      * @param date the date and time when the event occours
80      * @param message only if the event is a SYNC_ERROR, <p>null</p> otherwise
81      * @param cause only if the event is a SYNC_ERROR, <p>null</p> otherwise
82      */

83     public SyncEvent (int type ,
84                       long date ,
85                       String JavaDoc message ,
86                       Throwable JavaDoc cause ) {
87
88             this.type = type ;
89             this.date = new Date JavaDoc(date) ;
90             this.message = message ;
91             this.cause = cause ;
92
93     }
94
95     // -------------------------------------------------------- Public methods
96

97     public Throwable JavaDoc getCause () {
98         return cause;
99     }
100
101     public Date JavaDoc getDate () {
102         return date;
103     }
104
105     public String JavaDoc getMessage () {
106         return message;
107     }
108
109     public int getType () {
110         return type;
111     }
112
113     public void setCause (Throwable JavaDoc cause ) {
114         this.cause = cause ;
115     }
116
117     public void setDate (Date JavaDoc date ) {
118         this.date = date ;
119     }
120
121     public void setMessage (String JavaDoc message) {
122         this.message = message ;
123     }
124
125     public void setType (int type ) {
126         this.type = type ;
127     }
128
129     // -------------------------------------------------------- Private methods
130

131 }
Popular Tags