KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > calendar > model > Event


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//limitations under the License.
10
//
11
//The Original Code is "The Columba Project"
12
//
13
//The Initial Developers of the Original Code are Frederik Dietz and Timo
14
// Stich.
15
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16
//
17
//All Rights Reserved.
18
package org.columba.calendar.model;
19
20 import java.net.URL JavaDoc;
21 import java.util.Calendar JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24 import org.columba.calendar.base.UUIDGenerator;
25 import org.columba.calendar.model.api.IEvent;
26 import org.columba.calendar.model.api.IRecurrence;
27
28 public class Event extends Component implements IEvent {
29
30     private Calendar JavaDoc dtStart;
31
32     private Calendar JavaDoc dtEnd;
33
34     private String JavaDoc transsp;
35
36     private String JavaDoc summary;
37
38     private String JavaDoc description;
39
40     private String JavaDoc location;
41
42     private String JavaDoc priority;
43
44     private String JavaDoc eventClass;
45     
46     private String JavaDoc status;
47     
48     private boolean allDayEvent;
49     
50     private IRecurrence recurrence;
51         
52     private URL JavaDoc url;
53
54     private CategoryList categoryList = new CategoryList();
55
56     public Event() {
57         super(TYPE.EVENT);
58         
59         dtStart = Calendar.getInstance();
60         dtEnd = Calendar.getInstance();
61     }
62
63     public Event(String JavaDoc id) {
64         super(id, TYPE.EVENT);
65
66         dtStart = Calendar.getInstance();
67         dtEnd = Calendar.getInstance();
68     }
69
70     public Event(Calendar JavaDoc dtStart, Calendar JavaDoc dtEnd, String JavaDoc summary) {
71         super(TYPE.EVENT);
72
73         if (dtStart == null)
74             throw new IllegalArgumentException JavaDoc("dtStart == null");
75
76         if (dtEnd == null)
77             throw new IllegalArgumentException JavaDoc("dtEnd == null");
78
79         if (summary == null)
80             throw new IllegalArgumentException JavaDoc("summary == null");
81
82         this.dtStart = dtStart;
83         this.dtEnd = dtEnd;
84         this.summary = summary;
85
86     }
87
88     public Calendar JavaDoc getDtEnd() {
89         return dtEnd;
90     }
91
92     public String JavaDoc getLocation() {
93         return location;
94     }
95
96     public String JavaDoc getTranssp() {
97         return transsp;
98     }
99
100     public Calendar JavaDoc getDtStart() {
101         return dtStart;
102     }
103
104     public String JavaDoc getPriority() {
105         return priority;
106     }
107
108     public String JavaDoc getSummary() {
109         return summary;
110     }
111
112     public String JavaDoc getDescription() {
113         return description;
114     }
115
116     public URL JavaDoc getUrl() {
117         return url;
118     }
119
120     public String JavaDoc getEventClass() {
121         return eventClass;
122     }
123
124     public void addCategory(String JavaDoc category) {
125         categoryList.addCategory(category);
126     }
127
128     public void removeCategory(String JavaDoc category) {
129         categoryList.removeCategory(category);
130     }
131
132     public Iterator JavaDoc<String JavaDoc> getCategoryIterator() {
133         return categoryList.getCategoryIterator();
134     }
135
136     public String JavaDoc getCategories() {
137         return categoryList.getCategories();
138     }
139
140     public void setCategories(String JavaDoc categories) {
141         categoryList.setCategories(categories);
142     }
143
144     /**
145      * @param description
146      * The description to set.
147      */

148     public void setDescription(String JavaDoc description) {
149         this.description = description;
150     }
151
152     /**
153      * @param dtEnd
154      * The dtEnd to set.
155      */

156     public void setDtEnd(Calendar JavaDoc dtEnd) {
157         this.dtEnd = dtEnd;
158     }
159
160     /**
161      * @param dtStart
162      * The dtStart to set.
163      */

164     public void setDtStart(Calendar JavaDoc dtStart) {
165         this.dtStart = dtStart;
166     }
167
168     /**
169      * @param eventClass
170      * The eventClass to set.
171      */

172     public void setEventClass(String JavaDoc eventClass) {
173         this.eventClass = eventClass;
174     }
175
176     /**
177      * @param location
178      * The location to set.
179      */

180     public void setLocation(String JavaDoc location) {
181         this.location = location;
182     }
183
184     /**
185      * @param priority
186      * The priority to set.
187      */

188     public void setPriority(String JavaDoc priority) {
189         this.priority = priority;
190     }
191
192     /**
193      * @param summary
194      * The summary to set.
195      */

196     public void setSummary(String JavaDoc summary) {
197         this.summary = summary;
198     }
199
200     /**
201      * @param transsp
202      * The transsp to set.
203      */

204     public void setTranssp(String JavaDoc transsp) {
205         this.transsp = transsp;
206     }
207
208     /**
209      * @param url
210      * The url to set.
211      */

212     public void setUrl(URL JavaDoc url) {
213         this.url = url;
214     }
215
216     /**
217      * @see java.lang.Object#clone()
218      */

219     @Override JavaDoc
220     protected Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
221         // create new event with new UUID
222
Event event = new Event(new UUIDGenerator().newUUID());
223         // copy all attributes
224

225         event.setDtStart(getDtStart());
226         event.setDtEnd(getDtEnd());
227         event.setDtStamp(getDtStamp());
228         event.setSummary(getSummary());
229         event.setLocation(getLocation());
230         event.setCalendar(getCalendar());
231         
232         event.setAllDayEvent(isAllDayEvent());
233         
234         event.setRecurrence(getRecurrence());
235
236         return event;
237     }
238
239     public boolean isAllDayEvent() {
240         return allDayEvent;
241     }
242
243     public void setAllDayEvent(boolean allDayEventFlag) {
244         this.allDayEvent = allDayEventFlag;
245     }
246
247     public IRecurrence getRecurrence() {
248         return recurrence;
249     }
250
251     public void setRecurrence(IRecurrence recurrence) {
252         this.recurrence = recurrence;
253     }
254
255     public String JavaDoc getStatus() {
256         return status;
257     }
258
259     public void setStatus(String JavaDoc status) {
260         this.status = status;
261     }
262
263 }
264
Popular Tags