1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.custom.schedule.model;
21
22 import java.io.Serializable;
23
24 import java.util.Calendar;
25 import java.util.Date;
26 import java.util.TimeZone;
27
28 import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
29
30
31
32
33
34
35
36
37
38
39 public class DefaultScheduleEntry
40 implements Serializable, ScheduleEntry
41 {
42
43
44
45
46
47 private static final long serialVersionUID = 1L;
48 private Date endTime;
49 private Date startTime;
50 private String description;
51 private String id;
52 private String subtitle;
53 private String title;
54 private boolean allDay;
55 private TimeZone timeZone;
56
57
58
59
60
61
62 public TimeZone getTimeZone ()
63 {
64 return this.timeZone;
65 }
66
67
68
69
70
71 public void setTimeZone (TimeZone timeZone)
72 {
73 this.timeZone = timeZone;
74 }
75
76
77
78
79 public void setDescription(String description)
80 {
81 this.description = description;
82 }
83
84
85
86
87 public String getDescription()
88 {
89 return description;
90 }
91
92
93
94
95 public void setEndTime(Date endTime)
96 {
97 this.endTime = endTime;
98 }
99
100
101
102
103 public Date getEndTime()
104 {
105 if (endTime == null) endTime = new Date();
106 if (isAllDay()) {
107 Date truncated = ScheduleUtil.truncate(endTime, getTimeZone());
108 Calendar cal = ScheduleUtil.getCalendarInstance(truncated, getTimeZone());
109 cal.add(Calendar.MILLISECOND, -1);
110 truncated = cal.getTime();
111 if (!truncated.equals(endTime)) {
112 cal.add(Calendar.DATE, 1);
113 }
114 return cal.getTime();
115 }
116 return endTime;
117 }
118
119
120
121
122 public void setId(String id)
123 {
124 this.id = id;
125 }
126
127
128
129
130 public String getId()
131 {
132 return id;
133 }
134
135
136
137
138 public void setStartTime(Date startTime)
139 {
140 this.startTime = startTime;
141 }
142
143
144
145
146 public Date getStartTime()
147 {
148 if (startTime == null) startTime = new Date();
149 if (isAllDay()) {
150 return ScheduleUtil.truncate(startTime, getTimeZone());
151 } else {
152 return startTime;
153 }
154 }
155
156
157
158
159 public void setSubtitle(String subtitle)
160 {
161 this.subtitle = subtitle;
162 }
163
164
165
166
167 public String getSubtitle()
168 {
169 return subtitle;
170 }
171
172
173
174
175 public void setTitle(String title)
176 {
177 this.title = title;
178 }
179
180
181
182
183 public String getTitle()
184 {
185 return title;
186 }
187
188
189
190
191 public boolean isAllDay()
192 {
193 return allDay;
194 }
195
196
197
198
199 public void setAllDay(boolean allDay) {
200 this.allDay = allDay;
201 }
202
203 }
204