summaryrefslogtreecommitdiff
path: root/src/com/google/wireless/gdata/calendar/data/EventEntry.java
blob: 5f2f27114edd503022e512c69fb67ee96e0bb79e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// Copyright 2007 The Android Open Source Project

package com.google.wireless.gdata.calendar.data;

import com.google.wireless.gdata.data.Entry;

import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;

/**
 * Entry containing information about an event in a calendar.
 */
public class EventEntry extends Entry {

    // TODO: pack all of these enums into an int

    /**
     * Status constant indicating that a user's attendance at an event is
     * tentative.
     */
    public static final byte STATUS_TENTATIVE = 0;

    /**
     * Status constant indicating that a user's attendance at an event is
     * confirmed.
     */
    public static final byte STATUS_CONFIRMED = 1;

    /**
     * Status constant indicating that an event has been cancelled.
     */
    public static final byte STATUS_CANCELED = 2;

    /**
     * Visibility constant indicating that an event uses the user's default
     * visibility.
     */
    public static final byte VISIBILITY_DEFAULT = 0;

    /**
     * Visibility constant indicating that an event has been marked
     * confidential.
     */
    public static final byte VISIBILITY_CONFIDENTIAL = 1;

    /**
     * Visibility constant indicating that an event has been marked private.
     */
    public static final byte VISIBILITY_PRIVATE = 2;

    /**
     * Visibility constant indicating that an event has been marked public.
     */
    public static final byte VISIBILITY_PUBLIC = 3;

    /**
     * Transparency constant indicating that an event has been marked opaque.
     */
    public static final byte TRANSPARENCY_OPAQUE = 0;

    /**
     * Transparency constant indicating that an event has been marked
     * transparent.
     */
    public static final byte TRANSPARENCY_TRANSPARENT = 1;

    private byte status = STATUS_TENTATIVE;
    private String recurrence = null;
    private byte visibility = VISIBILITY_DEFAULT;
    private byte transparency = TRANSPARENCY_OPAQUE;
    private Vector attendees = new Vector();
    private Vector whens = new Vector();
    private Vector reminders = null;
    private String originalEventId = null;
    private String originalEventStartTime = null;
    private String where = null;
    private String commentsUri = null;
    private Hashtable extendedProperties = null;

    /**
     * Creates a new empty event entry.
     */
    public EventEntry() {
    }

    /*
     * (non-Javadoc)
     * @see com.google.wireless.gdata.data.Entry#clear()
     */
    public void clear() {
        super.clear();
        status = STATUS_TENTATIVE;
        recurrence = null;
        visibility = VISIBILITY_DEFAULT;
        transparency = TRANSPARENCY_OPAQUE;
        attendees.removeAllElements();
        whens.removeAllElements();
        reminders = null;
        originalEventId = null;
        originalEventStartTime = null;
        where = null;
        commentsUri = null;
        extendedProperties = null;
    }

    /**
     * @return the recurrence
     */
    public String getRecurrence() {
        return recurrence;
    }

    /**
     * @param recurrence the recurrence to set
     */
    public void setRecurrence(String recurrence) {
        this.recurrence = recurrence;
    }

    /**
     * @return the status
     */
    public byte getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(byte status) {
        this.status = status;
    }

    /**
     * @return the transparency
     */
    public byte getTransparency() {
        return transparency;
    }

    /**
     * @param transparency the transparency to set
     */
    public void setTransparency(byte transparency) {
        this.transparency = transparency;
    }

    /**
     * @return the visibility
     */
    public byte getVisibility() {
        return visibility;
    }

    /**
     * @param visibility the visibility to set
     */
    public void setVisibility(byte visibility) {
        this.visibility = visibility;
    }

    public void clearAttendees() {
        attendees.clear();
    }

    public void addAttendee(Who attendee) {
        attendees.add(attendee);
    }

    public Vector getAttendees() {
        return attendees;
    }

    public void clearWhens() {
        whens.clear();
    }

    public void addWhen(When when) {
        whens.add(when);
    }

    public Vector getWhens() {
        return whens;
    }

    public When getFirstWhen() {
        if (whens.isEmpty()) {
            return null;
        }
        return (When) whens.elementAt(0);
    }

    public Vector getReminders() {
        return reminders;
    }

    public void addReminder(Reminder reminder) {
        if (reminders == null) {
            reminders = new Vector();
        }
        reminders.add(reminder);
    }

    public void clearReminders() {
        reminders = null;
    }

    public String getOriginalEventId() {
        return originalEventId;
    }

    public void setOriginalEventId(String originalEventId) {
        this.originalEventId = originalEventId;
    }

    public String getOriginalEventStartTime() {
        return originalEventStartTime;
    }

    public void setOriginalEventStartTime(String originalEventStartTime) {
        this.originalEventStartTime = originalEventStartTime;
    }

    /**
     * @return the where
     */
    public String getWhere() {
        return where;
    }

    /**
     * @param where the where to set
     */
    public void setWhere(String where) {
        this.where = where;
    }

    public Hashtable getExtendedProperties() {
        return extendedProperties;
    }

    public String getExtendedProperty(String name) {
        if (extendedProperties == null) {
            return null;
        }
        String value = null;
        if (extendedProperties.containsKey(name)) {
            value = (String) extendedProperties.get(name);
        }
        return value;
    }

    public void addExtendedProperty(String name, String value) {
        if (extendedProperties == null) {
            extendedProperties = new Hashtable();
        }
        extendedProperties.put(name, value);
    }

    public void clearExtendedProperties() {
        extendedProperties = null;
    }

    public String getCommentsUri() {
        return commentsUri;
    }

    public void setCommentsUri(String commentsUri) {
        this.commentsUri = commentsUri;
    }

    public void toString(StringBuffer sb) {
        super.toString(sb);
        sb.append("STATUS: " + status + "\n");
        appendIfNotNull(sb, "RECURRENCE", recurrence);
        sb.append("VISIBILITY: " + visibility + "\n");
        sb.append("TRANSPARENCY: " + transparency + "\n");
        
        appendIfNotNull(sb, "ORIGINAL_EVENT_ID", originalEventId);
        appendIfNotNull(sb, "ORIGINAL_START_TIME", originalEventStartTime);

        Enumeration whos = this.attendees.elements();
        while (whos.hasMoreElements()) {
            Who who = (Who) whos.nextElement();
            who.toString(sb);
        }

        Enumeration times = this.whens.elements();
        while (times.hasMoreElements()) {
            When when = (When) times.nextElement();
            when.toString(sb);
        }
        if (reminders != null) {
            Enumeration alarms = reminders.elements();
            while (alarms.hasMoreElements()) {
                Reminder reminder = (Reminder) alarms.nextElement();
                reminder.toString(sb);
            }
        }
        appendIfNotNull(sb, "WHERE", where);
        appendIfNotNull(sb, "COMMENTS", commentsUri);
        if (extendedProperties != null) {
            Enumeration entryNames = extendedProperties.keys();
            while (entryNames.hasMoreElements()) {
                String name = (String) entryNames.nextElement();
                String value = (String) extendedProperties.get(name);
                sb.append(name);
                sb.append(':');
                sb.append(value);
                sb.append('\n');
            }
        }
    }
}