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 package net.fortuna.ical4j.model.component;
35
36 import net.fortuna.ical4j.model.Component;
37 import net.fortuna.ical4j.model.ComponentList;
38 import net.fortuna.ical4j.model.Property;
39 import net.fortuna.ical4j.model.PropertyList;
40 import net.fortuna.ical4j.model.ValidationException;
41 import net.fortuna.ical4j.util.PropertyValidator;
42
43 /***
44 * Defines an iCalendar VEVENT component.
45 *
46 * @author benf
47 */
48 public class VEvent extends Component {
49
50 private ComponentList alarms;
51
52 /***
53 * Constructor.
54 *
55 * @param aList
56 * a list of properties
57 */
58 public VEvent(final PropertyList aList) {
59
60 super(VEVENT, aList);
61 }
62
63 /***
64 * Constructor.
65 *
66 * @param aList
67 * a list of properties
68 * @param cList
69 * a list of alarms
70 */
71 public VEvent(final PropertyList aList, final ComponentList cList) {
72
73 super(VEVENT, aList);
74
75 this.alarms = cList;
76 }
77
78 /***
79 * @see java.lang.Object#toString()
80 */
81 public final String toString() {
82
83 if (alarms != null) {
84
85 return BEGIN + ":" + getName() + "\r\n" + getProperties() + alarms
86 + END + ":" + getName() + "\r\n"; }
87
88 return super.toString();
89 }
90
91 /***
92 * @see net.fortuna.ical4j.model.Component#validate(boolean)
93 */
94 public final void validate(boolean recurse) throws ValidationException {
95
96
97
98
99
100
101
102
103 PropertyValidator.getInstance().validateOneOrLess(Property.CLASS,
104 getProperties());
105 PropertyValidator.getInstance().validateOneOrLess(Property.CREATED,
106 getProperties());
107 PropertyValidator.getInstance().validateOneOrLess(Property.DESCRIPTION,
108 getProperties());
109 PropertyValidator.getInstance().validateOneOrLess(Property.DTSTART,
110 getProperties());
111 PropertyValidator.getInstance().validateOneOrLess(Property.GEO,
112 getProperties());
113 PropertyValidator.getInstance().validateOneOrLess(
114 Property.LAST_MODIFIED, getProperties());
115 PropertyValidator.getInstance().validateOneOrLess(Property.LOCATION,
116 getProperties());
117 PropertyValidator.getInstance().validateOneOrLess(Property.ORGANIZER,
118 getProperties());
119 PropertyValidator.getInstance().validateOneOrLess(Property.PRIORITY,
120 getProperties());
121 PropertyValidator.getInstance().validateOneOrLess(Property.DTSTAMP,
122 getProperties());
123 PropertyValidator.getInstance().validateOneOrLess(Property.SEQUENCE,
124 getProperties());
125 PropertyValidator.getInstance().validateOneOrLess(Property.STATUS,
126 getProperties());
127 PropertyValidator.getInstance().validateOneOrLess(Property.SUMMARY,
128 getProperties());
129 PropertyValidator.getInstance().validateOneOrLess(Property.TRANSP,
130 getProperties());
131 PropertyValidator.getInstance().validateOneOrLess(Property.UID,
132 getProperties());
133 PropertyValidator.getInstance().validateOneOrLess(Property.URL,
134 getProperties());
135 PropertyValidator.getInstance().validateOneOrLess(
136 Property.RECURRENCE_ID, getProperties());
137
138
139
140
141
142
143
144 if (getProperties().getProperty(Property.DTEND) != null
145 && getProperties().getProperty(Property.DURATION) != null) { throw new ValidationException(
146 "Properties [" + Property.DTEND + "," + Property.DURATION
147 + "] may not occur in the same VEVENT"); }
148
149
150
151
152
153
154
155
156 if (recurse) {
157 validateProperties();
158 }
159 }
160 }