KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > reminder > lookup > calendar > Event


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

19
20 package org.lucane.applications.reminder.lookup.calendar;
21
22 import java.awt.*;
23 import java.io.*;
24 import java.util.*;
25
26 public class Event implements Serializable
27 {
28     //-- recurrence
29
public static final int RECUR_NONE = 0;
30     public static final int RECUR_DAY = 1;
31     public static final int RECUR_WEEK = 2;
32     public static final int RECUR_MONTH = 3;
33     
34     //-- attributes
35
private int id;
36     private String JavaDoc type;
37     private Color color;
38     private String JavaDoc title;
39     private String JavaDoc organizer;
40     private boolean isPublic;
41     private long start;
42     private long end;
43     private int recurrence;
44     private String JavaDoc description;
45     
46     private ArrayList attendees;
47     private ArrayList resources;
48     
49     /**
50      * Constructor
51      */

52     public Event(int id, String JavaDoc type, String JavaDoc title, String JavaDoc organizer, boolean isPublic,
53                  long start, long end, int recurence, String JavaDoc description)
54     {
55         this.id = id;
56         this.type = type;
57         this.title = title;
58         this.organizer = organizer;
59         this.isPublic = isPublic;
60         this.start = start;
61         this.end = end;
62         this.recurrence = recurence;
63         this.description = description;
64         this.attendees = new ArrayList();
65         this.resources = new ArrayList();
66         this.color = Color.BLUE;
67     }
68     
69     //-- setters
70
public void setId(int id)
71     {
72         this.id = id;
73     }
74     
75     public void setAttendees(ArrayList attendees)
76     {
77         this.attendees = attendees;
78     }
79     
80     public void addAttendee(String JavaDoc user, boolean mandatory, int status)
81     {
82         this.attendees.add(new Attendee(user, mandatory, status));
83     }
84     
85     public Attendee getAttendee(String JavaDoc user)
86     {
87         Iterator i = getAttendees();
88         while(i.hasNext())
89         {
90             Attendee a = (Attendee)i.next();
91             if(a.getUser().equals(user))
92                 return a;
93         }
94         
95         return null;
96     }
97
98     public void setResources(ArrayList resources)
99     {
100         this.resources = resources;
101     }
102     
103     public void addResource(String JavaDoc resource)
104     {
105         this.resources.add(resource);
106     }
107     
108     public void setColor(Color color)
109     {
110         this.color = color;
111     }
112     
113     //-- getters
114
public int getId()
115     {
116         return this.id;
117     }
118     
119     public String JavaDoc getType()
120     {
121         return this.type;
122     }
123     
124     public String JavaDoc getOrganizer()
125     {
126         return this.organizer;
127     }
128     
129     public boolean isPublic()
130     {
131         return this.isPublic;
132     }
133     
134     public long getStartTime()
135     {
136         return this.start;
137     }
138     
139     public long getEndTime()
140     {
141         return this.end;
142     }
143     
144     public int getRecurrence()
145     {
146         return this.recurrence;
147     }
148     
149     public String JavaDoc getDescription()
150     {
151         return this.description;
152     }
153     
154     public Iterator getAttendees()
155     {
156         return this.attendees.iterator();
157     }
158     
159     public ArrayList getAttendeeList()
160     {
161         return this.attendees;
162     }
163     
164     public Iterator getResources()
165     {
166         return this.resources.iterator();
167     }
168     
169     
170     //-- getters for BasicEvent
171

172     public String JavaDoc getTitle()
173     {
174         return title;
175     }
176     
177     public int getStartHour()
178     {
179         Calendar c = Calendar.getInstance();
180         c.setTime(new Date(start));
181         return c.get(Calendar.HOUR_OF_DAY);
182     }
183
184     public int getStartMinute()
185     {
186         Calendar c = Calendar.getInstance();
187         c.setTime(new Date(start));
188         return c.get(Calendar.MINUTE);
189     }
190     
191     public int getEndHour()
192     {
193         Calendar c = Calendar.getInstance();
194         c.setTime(new Date(end));
195         return c.get(Calendar.HOUR_OF_DAY);
196     }
197
198     public int getEndMinute()
199     {
200         Calendar c = Calendar.getInstance();
201         c.setTime(new Date(end));
202         return c.get(Calendar.MINUTE);
203     }
204     
205     public Color getColor()
206     {
207         return this.color;
208     }
209     
210     public String JavaDoc toString()
211     {
212         return "[" + id + ": " + title +"]";
213     }
214 }
Popular Tags