src/net/fortuna/ical4j/model/component/VToDo.java

changeset 0
fb9019fb1bf7
child 3
73bdfa70b04e
equal deleted inserted replaced
-1:000000000000 0:3e88c2ba2450
1 /**
2 * Copyright (c) 2012, Ben Fortuna
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * o Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * o Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * o Neither the name of Ben Fortuna nor the names of any other contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 package net.fortuna.ical4j.model.component;
33
34 import java.io.IOException;
35 import java.net.URISyntaxException;
36 import java.text.ParseException;
37 import java.util.HashMap;
38 import java.util.Iterator;
39 import java.util.Map;
40
41 import net.fortuna.ical4j.model.Component;
42 import net.fortuna.ical4j.model.ComponentList;
43 import net.fortuna.ical4j.model.Date;
44 import net.fortuna.ical4j.model.Dur;
45 import net.fortuna.ical4j.model.Property;
46 import net.fortuna.ical4j.model.PropertyList;
47 import net.fortuna.ical4j.model.ValidationException;
48 import net.fortuna.ical4j.model.Validator;
49 import net.fortuna.ical4j.model.property.Clazz;
50 import net.fortuna.ical4j.model.property.Completed;
51 import net.fortuna.ical4j.model.property.Created;
52 import net.fortuna.ical4j.model.property.Description;
53 import net.fortuna.ical4j.model.property.DtStamp;
54 import net.fortuna.ical4j.model.property.DtStart;
55 import net.fortuna.ical4j.model.property.Due;
56 import net.fortuna.ical4j.model.property.Duration;
57 import net.fortuna.ical4j.model.property.Geo;
58 import net.fortuna.ical4j.model.property.LastModified;
59 import net.fortuna.ical4j.model.property.Location;
60 import net.fortuna.ical4j.model.property.Method;
61 import net.fortuna.ical4j.model.property.Organizer;
62 import net.fortuna.ical4j.model.property.PercentComplete;
63 import net.fortuna.ical4j.model.property.Priority;
64 import net.fortuna.ical4j.model.property.RecurrenceId;
65 import net.fortuna.ical4j.model.property.Sequence;
66 import net.fortuna.ical4j.model.property.Status;
67 import net.fortuna.ical4j.model.property.Summary;
68 import net.fortuna.ical4j.model.property.Uid;
69 import net.fortuna.ical4j.model.property.Url;
70 import net.fortuna.ical4j.util.CompatibilityHints;
71 import net.fortuna.ical4j.util.ComponentValidator;
72 import net.fortuna.ical4j.util.PropertyValidator;
73 import net.fortuna.ical4j.util.Strings;
74
75 import org.apache.commons.lang.ObjectUtils;
76 import org.apache.commons.lang.builder.HashCodeBuilder;
77
78 /**
79 * $Id$ [Apr 5, 2004]
80 *
81 * Defines an iCalendar VTODO component.
82 *
83 * <pre>
84 * 4.6.2 To-do Component
85 *
86 * Component Name: VTODO
87 *
88 * Purpose: Provide a grouping of calendar properties that describe a
89 * to-do.
90 *
91 * Formal Definition: A &quot;VTODO&quot; calendar component is defined by the
92 * following notation:
93 *
94 * todoc = &quot;BEGIN&quot; &quot;:&quot; &quot;VTODO&quot; CRLF
95 * todoprop *alarmc
96 * &quot;END&quot; &quot;:&quot; &quot;VTODO&quot; CRLF
97 *
98 * todoprop = *(
99 *
100 * ; the following are optional,
101 * ; but MUST NOT occur more than once
102 *
103 * class / completed / created / description / dtstamp /
104 * dtstart / geo / last-mod / location / organizer /
105 * percent / priority / recurid / seq / status /
106 * summary / uid / url /
107 *
108 * ; either 'due' or 'duration' may appear in
109 * ; a 'todoprop', but 'due' and 'duration'
110 * ; MUST NOT occur in the same 'todoprop'
111 *
112 * due / duration /
113 *
114 * ; the following are optional,
115 * ; and MAY occur more than once
116 * attach / attendee / categories / comment / contact /
117 * exdate / exrule / rstatus / related / resources /
118 * rdate / rrule / x-prop
119 *
120 * )
121 * </pre>
122 *
123 * Example 1 - Creating a todo of two (2) hour duration starting tomorrow:
124 *
125 * <pre><code>
126 * java.util.Calendar cal = java.util.Calendar.getInstance();
127 * // tomorrow..
128 * cal.add(java.util.Calendar.DAY_OF_MONTH, 1);
129 * cal.set(java.util.Calendar.HOUR_OF_DAY, 11);
130 * cal.set(java.util.Calendar.MINUTE, 00);
131 *
132 * VToDo documentation = new VEvent(cal.getTime(), 1000 * 60 * 60 * 2,
133 * &quot;Document calendar component usage&quot;);
134 *
135 * // add timezone information..
136 * VTimeZone tz = VTimeZone.getDefault();
137 * TzId tzParam = new TzId(tz.getProperties().getProperty(Property.TZID)
138 * .getValue());
139 * documentation.getProperties().getProperty(Property.DTSTART).getParameters()
140 * .add(tzParam);
141 * </code></pre>
142 *
143 * @author Ben Fortuna
144 */
145 public class VToDo extends CalendarComponent {
146
147 private static final long serialVersionUID = -269658210065896668L;
148
149 private final Map methodValidators = new HashMap();
150 {
151 methodValidators.put(Method.ADD, new AddValidator());
152 methodValidators.put(Method.CANCEL, new CancelValidator());
153 methodValidators.put(Method.COUNTER, new CounterValidator());
154 methodValidators.put(Method.DECLINE_COUNTER, new DeclineCounterValidator());
155 methodValidators.put(Method.PUBLISH, new PublishValidator());
156 methodValidators.put(Method.REFRESH, new RefreshValidator());
157 methodValidators.put(Method.REPLY, new ReplyValidator());
158 methodValidators.put(Method.REQUEST, new RequestValidator());
159 }
160
161 private ComponentList alarms = new ComponentList();
162
163 /**
164 * Default constructor.
165 */
166 public VToDo() {
167 super(VTODO);
168 getProperties().add(new DtStamp());
169 }
170
171 /**
172 * Constructor.
173 * @param properties a list of properties
174 */
175 public VToDo(final PropertyList properties) {
176 super(VTODO, properties);
177 }
178
179 /**
180 * Constructs a new VTODO instance starting at the specified time with the specified summary.
181 * @param start the start date of the new todo
182 * @param summary the todo summary
183 */
184 public VToDo(final Date start, final String summary) {
185 this();
186 getProperties().add(new DtStart(start));
187 getProperties().add(new Summary(summary));
188 }
189
190 /**
191 * Constructs a new VTODO instance starting and ending at the specified times with the specified summary.
192 * @param start the start date of the new todo
193 * @param due the due date of the new todo
194 * @param summary the todo summary
195 */
196 public VToDo(final Date start, final Date due, final String summary) {
197 this();
198 getProperties().add(new DtStart(start));
199 getProperties().add(new Due(due));
200 getProperties().add(new Summary(summary));
201 }
202
203 /**
204 * Constructs a new VTODO instance starting at the specified times, for the specified duration, with the specified
205 * summary.
206 * @param start the start date of the new todo
207 * @param duration the duration of the new todo
208 * @param summary the todo summary
209 */
210 public VToDo(final Date start, final Dur duration, final String summary) {
211 this();
212 getProperties().add(new DtStart(start));
213 getProperties().add(new Duration(duration));
214 getProperties().add(new Summary(summary));
215 }
216
217 /**
218 * Returns the list of alarms for this todo.
219 * @return a component list
220 */
221 public final ComponentList getAlarms() {
222 return alarms;
223 }
224
225 /**
226 * {@inheritDoc}
227 */
228 public final String toString() {
229 final StringBuffer buffer = new StringBuffer();
230 buffer.append(BEGIN);
231 buffer.append(':');
232 buffer.append(getName());
233 buffer.append(Strings.LINE_SEPARATOR);
234 buffer.append(getProperties());
235 buffer.append(getAlarms());
236 buffer.append(END);
237 buffer.append(':');
238 buffer.append(getName());
239 buffer.append(Strings.LINE_SEPARATOR);
240 return buffer.toString();
241 }
242
243 /**
244 * {@inheritDoc}
245 */
246 public final void validate(final boolean recurse)
247 throws ValidationException {
248
249 // validate that getAlarms() only contains VAlarm components
250 final Iterator iterator = getAlarms().iterator();
251 while (iterator.hasNext()) {
252 final Component component = (Component) iterator.next();
253 if (!(component instanceof VAlarm)) {
254 throw new ValidationException("Component ["
255 + component.getName() + "] may not occur in VTODO");
256 }
257 ((VAlarm) component).validate(recurse);
258 }
259
260 if (!CompatibilityHints
261 .isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) {
262
263 // From "4.8.4.7 Unique Identifier":
264 // Conformance: The property MUST be specified in the "VEVENT", "VTODO",
265 // "VJOURNAL" or "VFREEBUSY" calendar components.
266 PropertyValidator.getInstance().assertOne(Property.UID,
267 getProperties());
268
269 // From "4.8.7.2 Date/Time Stamp":
270 // Conformance: This property MUST be included in the "VEVENT", "VTODO",
271 // "VJOURNAL" or "VFREEBUSY" calendar components.
272 PropertyValidator.getInstance().assertOne(Property.DTSTAMP,
273 getProperties());
274 }
275
276 /*
277 * ; the following are optional, ; but MUST NOT occur more than once class / completed / created / description /
278 * dtstamp / dtstart / geo / last-mod / location / organizer / percent / priority / recurid / seq / status /
279 * summary / uid / url /
280 */
281 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS,
282 getProperties());
283 PropertyValidator.getInstance().assertOneOrLess(Property.COMPLETED,
284 getProperties());
285 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED,
286 getProperties());
287 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION,
288 getProperties());
289 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTAMP,
290 getProperties());
291 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART,
292 getProperties());
293 PropertyValidator.getInstance().assertOneOrLess(Property.GEO,
294 getProperties());
295 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED,
296 getProperties());
297 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION,
298 getProperties());
299 PropertyValidator.getInstance().assertOneOrLess(Property.ORGANIZER,
300 getProperties());
301 PropertyValidator.getInstance().assertOneOrLess(
302 Property.PERCENT_COMPLETE, getProperties());
303 PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY,
304 getProperties());
305 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID,
306 getProperties());
307 PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE,
308 getProperties());
309 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS,
310 getProperties());
311 PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY,
312 getProperties());
313 PropertyValidator.getInstance().assertOneOrLess(Property.UID,
314 getProperties());
315 PropertyValidator.getInstance().assertOneOrLess(Property.URL,
316 getProperties());
317
318 final Status status = (Status) getProperty(Property.STATUS);
319 if (status != null && !Status.VTODO_NEEDS_ACTION.getValue().equals(status.getValue())
320 && !Status.VTODO_COMPLETED.getValue().equals(status.getValue())
321 && !Status.VTODO_IN_PROCESS.getValue().equals(status.getValue())
322 && !Status.VTODO_CANCELLED.getValue().equals(status.getValue())) {
323 throw new ValidationException("Status property ["
324 + status.toString() + "] may not occur in VTODO");
325 }
326
327 /*
328 * ; either 'due' or 'duration' may appear in ; a 'todoprop', but 'due' and 'duration' ; MUST NOT occur in the
329 * same 'todoprop' due / duration /
330 */
331 try {
332 PropertyValidator.getInstance().assertNone(Property.DUE,
333 getProperties());
334 }
335 catch (ValidationException ve) {
336 PropertyValidator.getInstance().assertNone(Property.DURATION,
337 getProperties());
338 }
339
340 /*
341 * ; the following are optional, ; and MAY occur more than once attach / attendee / categories / comment /
342 * contact / exdate / exrule / rstatus / related / resources / rdate / rrule / x-prop
343 */
344
345 if (recurse) {
346 validateProperties();
347 }
348 }
349
350 /**
351 * {@inheritDoc}
352 */
353 protected Validator getValidator(Method method) {
354 return (Validator) methodValidators.get(method);
355 }
356
357 /**
358 * <pre>
359 * Component/Property Presence
360 * ------------------- ----------------------------------------------
361 * METHOD 1 MUST be "ADD"
362 * VTODO 1
363 * DTSTAMP 1
364 * ORGANIZER 1
365 * PRIORITY 1
366 * SEQUENCE 1 MUST be greater than 0
367 * SUMMARY 1 Can be null.
368 * UID 1 MUST match that of the original to-do
369 *
370 * ATTACH 0+
371 * ATTENDEE 0+
372 * CATEGORIES 0 or 1 This property may contain a list of
373 * values
374 * CLASS 0 or 1
375 * COMMENT 0 or 1
376 * CONTACT 0+
377 * CREATED 0 or 1
378 * DESCRIPTION 0 or 1 Can be null
379 * DTSTART 0 or 1
380 * DUE 0 or 1 If present DURATION MUST NOT be present
381 * DURATION 0 or 1 If present DUE MUST NOT be present
382 * EXDATE 0+
383 * EXRULE 0+
384 * GEO 0 or 1
385 * LAST-MODIFIED 0 or 1
386 * LOCATION 0 or 1
387 * PERCENT-COMPLETE 0 or 1
388 * RDATE 0+
389 * RELATED-TO 0+
390 * RESOURCES 0 or 1 This property may contain a list of
391 * values
392 * RRULE 0+
393 * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN-
394 * PROCESS
395 * URL 0 or 1
396 * X-PROPERTY 0+
397 *
398 * RECURRENCE-ID 0
399 * REQUEST-STATUS 0
400 *
401 * VALARM 0+
402 * VTIMEZONE 0+ MUST be present if any date/time refers
403 * to a timezone
404 * X-COMPONENT 0+
405 *
406 * VEVENT 0
407 * VJOURNAL 0
408 * VFREEBUSY 0
409 * </pre>
410 *
411 */
412 private class AddValidator implements Validator {
413
414 private static final long serialVersionUID = 1L;
415
416 public void validate() throws ValidationException {
417 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
418 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
419 PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties());
420 PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties());
421 PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties());
422 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
423
424 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
425 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
426 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
427 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
428 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
429 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties());
430 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
431 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
432 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
433 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
434 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
435 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
436 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
437 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
438 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
439
440 PropertyValidator.getInstance().assertNone(Property.RECURRENCE_ID, getProperties());
441 PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties());
442
443 for (final Iterator i = getAlarms().iterator(); i.hasNext();) {
444 final VAlarm alarm = (VAlarm) i.next();
445 alarm.validate(Method.ADD);
446 }
447 }
448 }
449
450 /**
451 * <pre>
452 * Component/Property Presence
453 * ------------------- ---------------------------------------------
454 * METHOD 1 MUST be "CANCEL"
455 * VTODO 1
456 * ATTENDEE 0+ include all "Attendees" being removed from
457 * the todo. MUST include all "Attendees" if
458 * the entire todo is cancelled.
459 * UID 1 MUST echo original UID
460 * DTSTAMP 1
461 * ORGANIZER 1
462 * SEQUENCE 1
463 *
464 * ATTACH 0+
465 * CATEGORIES 0 or 1 This property MAY contain a list of values
466 * CLASS 0 or 1
467 * COMMENT 0 or 1
468 * CONTACT 0+
469 * CREATED 0 or 1
470 * DESCRIPTION 0 or 1
471 * DTSTART 0 or 1
472 * DUE 0 or 1 If present DURATION MUST NOT be present
473 * DURATION 0 or 1 If present DUE MUST NOT be present
474 * EXDATE 0+
475 * EXRULE 0+
476 * GEO 0 or 1
477 * LAST-MODIFIED 0 or 1
478 * LOCATION 0 or 1
479 * PERCENT-COMPLETE 0 or 1
480 * RDATE 0+
481 * RECURRENCE-ID 0 or 1 MUST only if referring to one or more
482 * instances of a recurring calendar
483 * component. Otherwise it MUST NOT be
484 * present.
485 * RELATED-TO 0+
486 * RESOURCES 0 or 1 This property MAY contain a list of values
487 * RRULE 0+
488 * PRIORITY 0 or 1
489 * STATUS 0 or 1 If present it MUST be set to "CANCELLED".
490 * MUST NOT be used if purpose is to remove
491 * "ATTENDEES" rather than cancel the entire
492 * VTODO.
493 * URL 0 or 1
494 * X-PROPERTY 0+
495 *
496 * REQUEST-STATUS 0
497 *
498 * VTIMEZONE 0 or 1 MUST be present if any date/time refers to
499 * a timezone
500 * X-COMPONENT 0+
501 *
502 * VALARM 0
503 * VEVENT 0
504 * VFREEBUSY 0
505 * </pre>
506 *
507 */
508 private class CancelValidator implements Validator {
509
510 private static final long serialVersionUID = 1L;
511
512 public void validate() throws ValidationException {
513 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
514 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
515 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
516 PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties());
517
518 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
519 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
520 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
521 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
522 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
523 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties());
524 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
525 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
526 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
527 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
528 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
529 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
530 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
531 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
532 PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, getProperties());
533 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
534 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
535
536 PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties());
537
538 ComponentValidator.assertNone(Component.VALARM, getAlarms());
539 }
540 }
541
542 /**
543 * <pre>
544 * Component/Property Presence
545 * ------------------- ----------------------------------------------
546 * METHOD 1 MUST be "COUNTER"
547 * VTODO 1
548 * ATTENDEE 1+
549 * DTSTAMP 1
550 * ORGANIZER 1
551 * PRIORITY 1
552 * SUMMARY 1 Can be null
553 * UID 1
554 *
555 * ATTACH 0+
556 * CATEGORIES 0 or 1 This property MAY contain a list of values
557 * CLASS 0 or 1
558 * COMMENT 0 or 1
559 * CONTACT 0+
560 * CREATED 0 or 1
561 * DESCRIPTION 0 or 1 Can be null
562 * DTSTART 0 or 1
563 * DUE 0 or 1 If present DURATION MUST NOT be present
564 * DURATION 0 or 1 If present DUE MUST NOT be present
565 * EXDATE 0+
566 * EXRULE 0+
567 * GEO 0 or 1
568 * LAST-MODIFIED 0 or 1
569 * LOCATION 0 or 1
570 * PERCENT-COMPLETE 0 or 1
571 * RDATE 0+
572 * RECURRENCE-ID 0 or 1 MUST only 3.5if referring to an instance of a
573 * recurring calendar component. Otherwise it
574 * MUST NOT be present.
575 * RELATED-TO 0+
576 * REQUEST-STATUS 0+
577 * RESOURCES 0 or 1 This property MAY contain a list of values
578 * RRULE 0 or 1
579 * SEQUENCE 0 or 1 MUST echo the original SEQUENCE number.
580 * MUST be present if non-zero. MAY be present
581 * if zero.
582 * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN-
583 * PROCESS/CANCELLED
584 * URL 0 or 1
585 * X-PROPERTY 0+
586 *
587 *
588 * VALARM 0+
589 * VTIMEZONE 0 or 1 MUST be present if any date/time refers to
590 * a timezone
591 * X-COMPONENT 0+
592 *
593 * VEVENT 0
594 * VFREEBUSY 0
595 * </pre>
596 *
597 */
598 private class CounterValidator implements Validator {
599
600 private static final long serialVersionUID = 1L;
601
602 public void validate() throws ValidationException {
603 PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties());
604
605 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
606 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
607 PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties());
608 PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties());
609 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
610
611 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
612 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
613 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
614 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
615 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
616 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties());
617 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
618 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
619 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
620 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
621 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
622 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
623 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
624 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
625 PropertyValidator.getInstance().assertOneOrLess(Property.RRULE, getProperties());
626 PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties());
627 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
628 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
629
630 for (final Iterator i = getAlarms().iterator(); i.hasNext();) {
631 final VAlarm alarm = (VAlarm) i.next();
632 alarm.validate(Method.COUNTER);
633 }
634 }
635 }
636
637 /**
638 * <pre>
639 * Component/Property Presence
640 * ------------------- ---------------------------------------------
641 * METHOD 1 MUST be "DECLINECOUNTER"
642 *
643 * VTODO 1
644 * ATTENDEE 1+ MUST for all attendees
645 * DTSTAMP 1
646 * ORGANIZER 1
647 * SEQUENCE 1 MUST echo the original SEQUENCE number
648 * UID 1 MUST echo original UID
649 * ATTACH 0+
650 * CATEGORIES 0 or 1 This property may contain a list of values
651 * CLASS 0 or 1
652 * COMMENT 0 or 1
653 * CONTACT 0+
654 * CREATED 0 or 1
655 * DESCRIPTION 0 or 1
656 * DTSTART 0 or 1
657 * DUE 0 or 1 If present DURATION MUST NOT be present
658 * DURATION 0 or 1 If present DUE MUST NOT be present
659 * EXDATE 0+
660 * EXRULE 0+
661 * GEO 0 or 1
662 * LAST-MODIFIED 0 or 1
663 * LOCATION 0 or 1
664 * PERCENT-COMPLETE 0 or 1
665 * PRIORITY 0 or 1
666 * RDATE 0+
667 * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a
668 * recurring calendar component. Otherwise
669 * it MUST NOT be present.
670 * RELATED-TO 0+
671 * REQUEST-STATUS 0+
672 * RESOURCES 0 or 1 This property MAY contain a list of values
673 * RRULE 0+
674 * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN-
675 * PROCESS
676 * URL 0 or 1
677 * X-PROPERTY 0+
678 *
679 * VTIMEZONE 0+ MUST be present if any date/time refers to
680 * a timezone
681 * X-COMPONENT 0+
682 *
683 * VALARM 0
684 * VEVENT 0
685 * VFREEBUSY 0
686 * </pre>
687 *
688 */
689 private class DeclineCounterValidator implements Validator {
690
691 private static final long serialVersionUID = 1L;
692
693 public void validate() throws ValidationException {
694 PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties());
695
696 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
697 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
698 PropertyValidator.getInstance().assertOne(Property.SEQUENCE, getProperties());
699 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
700
701 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
702 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
703 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
704 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
705 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
706 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties());
707 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
708 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
709 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
710 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
711 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
712 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
713 PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, getProperties());
714 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
715 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
716 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
717 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
718
719 ComponentValidator.assertNone(Component.VALARM, getAlarms());
720 }
721 }
722
723 /**
724 * <pre>
725 * Component/Property Presence
726 * ------------------- ----------------------------------------------
727 * METHOD 1 MUST be "PUBLISH"
728 * VTODO 1+
729 * DTSTAMP 1
730 * DTSTART 1
731 * ORGANIZER 1
732 * PRIORITY 1
733 * SEQUENCE 0 or 1 MUST be present if value is greater than
734 * 0, MAY be present if 0
735 * SUMMARY 1 Can be null.
736 * UID 1
737 *
738 * ATTACH 0+
739 * CATEGORIES 0 or 1 This property may contain a list of values
740 * CLASS 0 or 1
741 * COMMENT 0 or 1
742 * CONTACT 0+
743 * CREATED 0 or 1
744 * DESCRIPTION 0 or 1 Can be null
745 * DUE 0 or 1 If present DURATION MUST NOT be present
746 * DURATION 0 or 1 If present DUE MUST NOT be present
747 * EXDATE 0+
748 * EXRULE 0+
749 * GEO 0 or 1
750 * LAST-MODIFIED 0 or 1
751 * LOCATION 0 or 1
752 * PERCENT-COMPLETE 0 or 1
753 * RDATE 0+
754 * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a
755 * recurring calendar component. Otherwise
756 * it MUST NOT be present.
757 *
758 * RELATED-TO 0+
759 * RESOURCES 0 or 1 This property may contain a list of values
760 * RRULE 0+
761 * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN-
762 * PROCESS/CANCELLED
763 * URL 0 or 1
764 * X-PROPERTY 0+
765 *
766 * ATTENDEE 0
767 * REQUEST-STATUS 0
768 *
769 * VTIMEZONE 0+ MUST be present if any date/time refers to
770 * a timezone
771 * VALARM 0+
772 * X-COMPONENT 0+
773 *
774 * VFREEBUSY 0
775 * VEVENT 0
776 * VJOURNAL 0
777 * </pre>
778 *
779 */
780 private class PublishValidator implements Validator {
781
782 private static final long serialVersionUID = 1L;
783
784 public void validate() throws ValidationException {
785 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
786
787 if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) {
788 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
789 PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties());
790 }
791
792 PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties());
793 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
794
795 // DTSTART: RFC2446 conflicts with RCF2445..
796 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties());
797 PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties());
798 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
799 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
800 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
801 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
802 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
803 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
804 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
805 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
806 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
807 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
808 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
809 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
810 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
811 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
812 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
813
814 PropertyValidator.getInstance().assertNone(Property.ATTENDEE, getProperties());
815 PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties());
816
817 for (final Iterator i = getAlarms().iterator(); i.hasNext();) {
818 final VAlarm alarm = (VAlarm) i.next();
819 alarm.validate(Method.PUBLISH);
820 }
821 }
822 }
823
824 /**
825 * <pre>
826 * Component/Property Presence
827 * ------------------- ---------------------------------------------
828 * METHOD 1 MUST be "REFRESH"
829 * VTODO 1
830 * ATTENDEE 1
831 * DTSTAMP 1
832 * UID 1 MUST echo original UID
833 *
834 * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a
835 * Recurring calendar component. Otherwise it
836 * MUST NOT be present
837 * X-PROPERTY 0+
838 *
839 * ATTACH 0
840 * CATEGORIES 0
841 * CLASS 0
842 * COMMENT 0
843 * CONTACT 0
844 * CREATED 0
845 * DESCRIPTION 0
846 * DTSTART 0
847 * DUE 0
848 * DURATION 0
849 * EXDATE 0
850 * EXRULE 0
851 * GEO 0
852 * LAST-MODIFIED 0
853 * LOCATION 0
854 * ORGANIZER 0
855 * PERCENT-COMPLETE 0
856 * PRIORITY 0
857 * RDATE 0
858 * RELATED-TO 0
859 * REQUEST-STATUS 0
860 * RESOURCES 0
861 * RRULE 0
862 * SEQUENCE 0
863 * STATUS 0
864 * URL 0
865 *
866 * X-COMPONENT 0+
867 *
868 * VALARM 0
869 * VEVENT 0
870 * VFREEBUSY 0
871 * VTIMEZONE 0
872 * </pre>
873 *
874 */
875 private class RefreshValidator implements Validator {
876
877 private static final long serialVersionUID = 1L;
878
879 public void validate() throws ValidationException {
880 PropertyValidator.getInstance().assertOne(Property.ATTENDEE, getProperties());
881 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
882 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
883
884 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
885
886 PropertyValidator.getInstance().assertNone(Property.ATTACH, getProperties());
887 PropertyValidator.getInstance().assertNone(Property.CATEGORIES, getProperties());
888 PropertyValidator.getInstance().assertNone(Property.CLASS, getProperties());
889 PropertyValidator.getInstance().assertNone(Property.COMMENT, getProperties());
890 PropertyValidator.getInstance().assertNone(Property.CONTACT, getProperties());
891 PropertyValidator.getInstance().assertNone(Property.CREATED, getProperties());
892 PropertyValidator.getInstance().assertNone(Property.DESCRIPTION, getProperties());
893 PropertyValidator.getInstance().assertNone(Property.DTSTART, getProperties());
894 PropertyValidator.getInstance().assertNone(Property.DUE, getProperties());
895 PropertyValidator.getInstance().assertNone(Property.DURATION, getProperties());
896 PropertyValidator.getInstance().assertNone(Property.EXDATE, getProperties());
897 PropertyValidator.getInstance().assertNone(Property.EXRULE, getProperties());
898 PropertyValidator.getInstance().assertNone(Property.GEO, getProperties());
899 PropertyValidator.getInstance().assertNone(Property.LAST_MODIFIED, getProperties());
900 PropertyValidator.getInstance().assertNone(Property.LOCATION, getProperties());
901 PropertyValidator.getInstance().assertNone(Property.ORGANIZER, getProperties());
902 PropertyValidator.getInstance().assertNone(Property.PERCENT_COMPLETE, getProperties());
903 PropertyValidator.getInstance().assertNone(Property.PRIORITY, getProperties());
904 PropertyValidator.getInstance().assertNone(Property.RDATE, getProperties());
905 PropertyValidator.getInstance().assertNone(Property.RELATED_TO, getProperties());
906 PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties());
907 PropertyValidator.getInstance().assertNone(Property.RESOURCES, getProperties());
908 PropertyValidator.getInstance().assertNone(Property.RRULE, getProperties());
909 PropertyValidator.getInstance().assertNone(Property.SEQUENCE, getProperties());
910 PropertyValidator.getInstance().assertNone(Property.STATUS, getProperties());
911 PropertyValidator.getInstance().assertNone(Property.URL, getProperties());
912
913 ComponentValidator.assertNone(Component.VALARM, getAlarms());
914 }
915 }
916
917 /**
918 * <pre>
919 * Component/Property Presence
920 * ------------------- ---------------------------------------------
921 * METHOD 1 MUST be "REPLY"
922 * VTODO 1+ All component MUST have the same UID
923 * ATTENDEE 1+
924 * DTSTAMP 1
925 * ORGANIZER 1
926 * UID 1 MUST must be the address of the replying
927 * attendee
928 * REQUEST-STATUS 0+
929 * ATTACH 0+
930 * CATEGORIES 0 or 1 This property may contain a list of values
931 * CLASS 0 or 1
932 * COMMENT 0 or 1
933 * CONTACT 0+
934 * CREATED 0 or 1
935 * DESCRIPTION 0 or 1
936 * DTSTART 0 or 1
937 * DUE 0 or 1 If present DURATION MUST NOT be present
938 * DURATION 0 or 1 If present DUE MUST NOT be present
939 * EXDATE 0+
940 * EXRULE 0+
941 * GEO 0 or 1
942 * LAST-MODIFIED 0 or 1
943 * LOCATION 0 or 1
944 * PERCENT-COMPLETE 0 or 1
945 * PRIORITY 0 or 1
946 * RDATE 0+
947 * RELATED-TO 0+
948 * RESOURCES 0 or 1 This property may contain a list of values
949 * RRULE 0+
950 * RECURRENCE-ID 0 or 1 MUST only if referring to an instance of a
951 * Recurring calendar component. Otherwise it
952 * MUST NOT be present
953 * SEQUENCE 0 or 1 MUST be the sequence number of
954 * the original REQUEST if greater than 0.
955 * MAY be present if 0.
956 * STATUS 0 or 1
957 * SUMMARY 0 or 1 Can be null
958 * URL 0 or 1
959 * X-PROPERTY 0+
960 *
961 * VTIMEZONE 0 or 1 MUST be present if any date/time refers to
962 * a timezone
963 * X-COMPONENT 0+
964 *
965 * VALARM 0
966 * VEVENT 0
967 * VFREEBUSY 0
968 * </pre>
969 *
970 */
971 private class ReplyValidator implements Validator {
972
973 private static final long serialVersionUID = 1L;
974
975 public void validate() throws ValidationException {
976 PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties());
977
978 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
979 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
980 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
981
982 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
983 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
984 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
985 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
986 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
987 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTART, getProperties());
988 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
989 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
990 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
991 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
992 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
993 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
994 PropertyValidator.getInstance().assertOneOrLess(Property.PRIORITY, getProperties());
995 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
996 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
997 PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties());
998 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
999 PropertyValidator.getInstance().assertOneOrLess(Property.SUMMARY, getProperties());
1000 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
1001
1002 ComponentValidator.assertNone(Component.VALARM, getAlarms());
1003 }
1004 }
1005
1006 /**
1007 * <pre>
1008 * Component/Property Presence
1009 * ------------------- ----------------------------------------------
1010 * METHOD 1 MUST be "REQUEST"
1011 * VTODO 1+ All components must have the same UID
1012 * ATTENDEE 1+
1013 * DTSTAMP 1
1014 * DTSTART 1
1015 * ORGANIZER 1
1016 * PRIORITY 1
1017 * SEQUENCE 0 or 1 MUST be present if value is greater than
1018 * 0, MAY be present if 0
1019 * SUMMARY 1 Can be null.
1020 * UID 1
1021 *
1022 * ATTACH 0+
1023 * CATEGORIES 0 or 1 This property may contain a list of
1024 * values
1025 * CLASS 0 or 1
1026 * COMMENT 0 or 1
1027 * CONTACT 0+
1028 * CREATED 0 or 1
1029 * DESCRIPTION 0 or 1 Can be null
1030 * DUE 0 or 1 If present DURATION MUST NOT be present
1031 * DURATION 0 or 1 If present DUE MUST NOT be present
1032 * EXDATE 0+
1033 * EXRULE 0+
1034 * GEO 0 or 1
1035 * LAST-MODIFIED 0 or 1
1036 * LOCATION 0 or 1
1037 * PERCENT-COMPLETE 0 or 1
1038 * RDATE 0+
1039 * RECURRENCE-ID 0 or 1 present if referring to an instance of a
1040 * recurring calendar component. Otherwise
1041 * it MUST NOT be present.
1042 * RELATED-TO 0+
1043 * RESOURCES 0 or 1 This property may contain a list of
1044 * values
1045 * RRULE 0+
1046 * STATUS 0 or 1 MAY be one of COMPLETED/NEEDS ACTION/IN-
1047 * PROCESS
1048 * URL 0 or 1
1049 * X-PROPERTY 0+
1050 *
1051 * REQUEST-STATUS 0
1052 *
1053 * VALARM 0+
1054 *
1055 * VTIMEZONE 0+ MUST be present if any date/time refers
1056 * to a timezone
1057 * X-COMPONENT 0+
1058 *
1059 * VEVENT 0
1060 * VFREEBUSY 0
1061 * VJOURNAL 0
1062 * </pre>
1063 *
1064 */
1065 private class RequestValidator implements Validator {
1066
1067 private static final long serialVersionUID = 1L;
1068
1069 public void validate() throws ValidationException {
1070 PropertyValidator.getInstance().assertOneOrMore(Property.ATTENDEE, getProperties());
1071
1072 PropertyValidator.getInstance().assertOne(Property.DTSTAMP, getProperties());
1073 PropertyValidator.getInstance().assertOne(Property.DTSTART, getProperties());
1074 PropertyValidator.getInstance().assertOne(Property.ORGANIZER, getProperties());
1075 PropertyValidator.getInstance().assertOne(Property.PRIORITY, getProperties());
1076 PropertyValidator.getInstance().assertOne(Property.SUMMARY, getProperties());
1077 PropertyValidator.getInstance().assertOne(Property.UID, getProperties());
1078
1079 PropertyValidator.getInstance().assertOneOrLess(Property.SEQUENCE, getProperties());
1080 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, getProperties());
1081 PropertyValidator.getInstance().assertOneOrLess(Property.CLASS, getProperties());
1082 PropertyValidator.getInstance().assertOneOrLess(Property.COMMENT, getProperties());
1083 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, getProperties());
1084 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, getProperties());
1085 PropertyValidator.getInstance().assertOneOrLess(Property.DUE, getProperties());
1086 PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties());
1087 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, getProperties());
1088 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, getProperties());
1089 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION, getProperties());
1090 PropertyValidator.getInstance().assertOneOrLess(Property.PERCENT_COMPLETE, getProperties());
1091 PropertyValidator.getInstance().assertOneOrLess(Property.RECURRENCE_ID, getProperties());
1092 PropertyValidator.getInstance().assertOneOrLess(Property.RESOURCES, getProperties());
1093 PropertyValidator.getInstance().assertOneOrLess(Property.STATUS, getProperties());
1094 PropertyValidator.getInstance().assertOneOrLess(Property.URL, getProperties());
1095
1096 PropertyValidator.getInstance().assertNone(Property.REQUEST_STATUS, getProperties());
1097
1098 for (final Iterator i = getAlarms().iterator(); i.hasNext();) {
1099 final VAlarm alarm = (VAlarm) i.next();
1100 alarm.validate(Method.REQUEST);
1101 }
1102 }
1103 }
1104
1105 /**
1106 * @return the optional access classification property
1107 */
1108 public final Clazz getClassification() {
1109 return (Clazz) getProperty(Property.CLASS);
1110 }
1111
1112 /**
1113 * @return the optional date completed property
1114 */
1115 public final Completed getDateCompleted() {
1116 return (Completed) getProperty(Property.COMPLETED);
1117 }
1118
1119 /**
1120 * @return the optional creation-time property
1121 */
1122 public final Created getCreated() {
1123 return (Created) getProperty(Property.CREATED);
1124 }
1125
1126 /**
1127 * @return the optional description property
1128 */
1129 public final Description getDescription() {
1130 return (Description) getProperty(Property.DESCRIPTION);
1131 }
1132
1133 /**
1134 * Convenience method to pull the DTSTART out of the property list.
1135 * @return The DtStart object representation of the start Date
1136 */
1137 public final DtStart getStartDate() {
1138 return (DtStart) getProperty(Property.DTSTART);
1139 }
1140
1141 /**
1142 * @return the optional geographic position property
1143 */
1144 public final Geo getGeographicPos() {
1145 return (Geo) getProperty(Property.GEO);
1146 }
1147
1148 /**
1149 * @return the optional last-modified property
1150 */
1151 public final LastModified getLastModified() {
1152 return (LastModified) getProperty(Property.LAST_MODIFIED);
1153 }
1154
1155 /**
1156 * @return the optional location property
1157 */
1158 public final Location getLocation() {
1159 return (Location) getProperty(Property.LOCATION);
1160 }
1161
1162 /**
1163 * @return the optional organizer property
1164 */
1165 public final Organizer getOrganizer() {
1166 return (Organizer) getProperty(Property.ORGANIZER);
1167 }
1168
1169 /**
1170 * @return the optional percentage complete property
1171 */
1172 public final PercentComplete getPercentComplete() {
1173 return (PercentComplete) getProperty(Property.PERCENT_COMPLETE);
1174 }
1175
1176 /**
1177 * @return the optional priority property
1178 */
1179 public final Priority getPriority() {
1180 return (Priority) getProperty(Property.PRIORITY);
1181 }
1182
1183 /**
1184 * @return the optional date-stamp property
1185 */
1186 public final DtStamp getDateStamp() {
1187 return (DtStamp) getProperty(Property.DTSTAMP);
1188 }
1189
1190 /**
1191 * @return the optional sequence number property
1192 */
1193 public final Sequence getSequence() {
1194 return (Sequence) getProperty(Property.SEQUENCE);
1195 }
1196
1197 /**
1198 * @return the optional status property
1199 */
1200 public final Status getStatus() {
1201 return (Status) getProperty(Property.STATUS);
1202 }
1203
1204 /**
1205 * @return the optional summary property
1206 */
1207 public final Summary getSummary() {
1208 return (Summary) getProperty(Property.SUMMARY);
1209 }
1210
1211 /**
1212 * @return the optional URL property
1213 */
1214 public final Url getUrl() {
1215 return (Url) getProperty(Property.URL);
1216 }
1217
1218 /**
1219 * @return the optional recurrence identifier property
1220 */
1221 public final RecurrenceId getRecurrenceId() {
1222 return (RecurrenceId) getProperty(Property.RECURRENCE_ID);
1223 }
1224
1225 /**
1226 * @return the optional Duration property
1227 */
1228 public final Duration getDuration() {
1229 return (Duration) getProperty(Property.DURATION);
1230 }
1231
1232 /**
1233 * @return the optional due property
1234 */
1235 public final Due getDue() {
1236 return (Due) getProperty(Property.DUE);
1237 }
1238
1239 /**
1240 * Returns the UID property of this component if available.
1241 * @return a Uid instance, or null if no UID property exists
1242 */
1243 public final Uid getUid() {
1244 return (Uid) getProperty(Property.UID);
1245 }
1246
1247 /**
1248 * {@inheritDoc}
1249 */
1250 public boolean equals(final Object arg0) {
1251 if (arg0 instanceof VToDo) {
1252 return super.equals(arg0)
1253 && ObjectUtils.equals(alarms, ((VToDo) arg0).getAlarms());
1254 }
1255 return super.equals(arg0);
1256 }
1257
1258 /**
1259 * {@inheritDoc}
1260 */
1261 public int hashCode() {
1262 return new HashCodeBuilder().append(getName()).append(getProperties())
1263 .append(getAlarms()).toHashCode();
1264 }
1265
1266 /**
1267 * Overrides default copy method to add support for copying alarm sub-components.
1268 * @return a copy of the instance
1269 * @throws ParseException where an error occurs parsing data
1270 * @throws IOException where an error occurs reading data
1271 * @throws URISyntaxException where an invalid URI is encountered
1272 * @see net.fortuna.ical4j.model.Component#copy()
1273 */
1274 public Component copy() throws ParseException, IOException, URISyntaxException {
1275 final VToDo copy = (VToDo) super.copy();
1276 copy.alarms = new ComponentList(alarms);
1277 return copy;
1278 }
1279 }

mercurial