001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.calendar.model;
019:
020: import java.net.URL;
021: import java.util.Calendar;
022: import java.util.Iterator;
023:
024: import org.columba.calendar.base.UUIDGenerator;
025: import org.columba.calendar.model.api.IEvent;
026: import org.columba.calendar.model.api.IRecurrence;
027:
028: public class Event extends Component implements IEvent {
029:
030: private Calendar dtStart;
031:
032: private Calendar dtEnd;
033:
034: private String transsp;
035:
036: private String summary;
037:
038: private String description;
039:
040: private String location;
041:
042: private String priority;
043:
044: private String eventClass;
045:
046: private String status;
047:
048: private boolean allDayEvent;
049:
050: private IRecurrence recurrence;
051:
052: private URL url;
053:
054: private CategoryList categoryList = new CategoryList();
055:
056: public Event() {
057: super (TYPE.EVENT);
058:
059: dtStart = Calendar.getInstance();
060: dtEnd = Calendar.getInstance();
061: }
062:
063: public Event(String id) {
064: super (id, TYPE.EVENT);
065:
066: dtStart = Calendar.getInstance();
067: dtEnd = Calendar.getInstance();
068: }
069:
070: public Event(Calendar dtStart, Calendar dtEnd, String summary) {
071: super (TYPE.EVENT);
072:
073: if (dtStart == null)
074: throw new IllegalArgumentException("dtStart == null");
075:
076: if (dtEnd == null)
077: throw new IllegalArgumentException("dtEnd == null");
078:
079: if (summary == null)
080: throw new IllegalArgumentException("summary == null");
081:
082: this .dtStart = dtStart;
083: this .dtEnd = dtEnd;
084: this .summary = summary;
085:
086: }
087:
088: public Calendar getDtEnd() {
089: return dtEnd;
090: }
091:
092: public String getLocation() {
093: return location;
094: }
095:
096: public String getTranssp() {
097: return transsp;
098: }
099:
100: public Calendar getDtStart() {
101: return dtStart;
102: }
103:
104: public String getPriority() {
105: return priority;
106: }
107:
108: public String getSummary() {
109: return summary;
110: }
111:
112: public String getDescription() {
113: return description;
114: }
115:
116: public URL getUrl() {
117: return url;
118: }
119:
120: public String getEventClass() {
121: return eventClass;
122: }
123:
124: public void addCategory(String category) {
125: categoryList.addCategory(category);
126: }
127:
128: public void removeCategory(String category) {
129: categoryList.removeCategory(category);
130: }
131:
132: public Iterator<String> getCategoryIterator() {
133: return categoryList.getCategoryIterator();
134: }
135:
136: public String getCategories() {
137: return categoryList.getCategories();
138: }
139:
140: public void setCategories(String categories) {
141: categoryList.setCategories(categories);
142: }
143:
144: /**
145: * @param description
146: * The description to set.
147: */
148: public void setDescription(String description) {
149: this .description = description;
150: }
151:
152: /**
153: * @param dtEnd
154: * The dtEnd to set.
155: */
156: public void setDtEnd(Calendar dtEnd) {
157: this .dtEnd = dtEnd;
158: }
159:
160: /**
161: * @param dtStart
162: * The dtStart to set.
163: */
164: public void setDtStart(Calendar dtStart) {
165: this .dtStart = dtStart;
166: }
167:
168: /**
169: * @param eventClass
170: * The eventClass to set.
171: */
172: public void setEventClass(String eventClass) {
173: this .eventClass = eventClass;
174: }
175:
176: /**
177: * @param location
178: * The location to set.
179: */
180: public void setLocation(String location) {
181: this .location = location;
182: }
183:
184: /**
185: * @param priority
186: * The priority to set.
187: */
188: public void setPriority(String priority) {
189: this .priority = priority;
190: }
191:
192: /**
193: * @param summary
194: * The summary to set.
195: */
196: public void setSummary(String summary) {
197: this .summary = summary;
198: }
199:
200: /**
201: * @param transsp
202: * The transsp to set.
203: */
204: public void setTranssp(String transsp) {
205: this .transsp = transsp;
206: }
207:
208: /**
209: * @param url
210: * The url to set.
211: */
212: public void setUrl(URL url) {
213: this .url = url;
214: }
215:
216: /**
217: * @see java.lang.Object#clone()
218: */
219: @Override
220: protected Object clone() throws CloneNotSupportedException {
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 getStatus() {
256: return status;
257: }
258:
259: public void setStatus(String status) {
260: this.status = status;
261: }
262:
263: }
|