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;
35
36 /***
37 * Defines an iCalendar property. Subclasses of this class provide additional
38 * validation and typed values for specific iCalendar properties.
39 *
40 * @author benf
41 */
42 public abstract class Property {
43
44
45
46 /***
47 * 'prodid' and 'version' are both REQUIRED, but MUST NOT occur more than
48 * once
49 */
50 public static final String PRODID = "PRODID";
51
52 public static final String VERSION = "VERSION";
53
54 /***
55 * 'calscale' and 'method' are optional, but MUST NOT occur more than once
56 */
57 public static final String CALSCALE = "CALSCALE";
58
59 public static final String METHOD = "METHOD";
60
61
62
63 /***
64 * the following are optional, but MUST NOT occur more than once
65 */
66 public static final String CLASS = "CLASS";
67
68 public static final String CREATED = "CREATED";
69
70 public static final String DESCRIPTION = "DESCRIPTION";
71
72 public static final String DTSTART = "DTSTART";
73
74 public static final String GEO = "GEO";
75
76 public static final String LAST_MODIFIED = "LAST-MODIFIED";
77
78 public static final String LOCATION = "LOCATION";
79
80 public static final String ORGANIZER = "ORGANIZER";
81
82 public static final String PERCENT_COMPLETE = "PERCENT-COMPLETE";
83
84 public static final String PRIORITY = "PRIORITY";
85
86 public static final String DTSTAMP = "DTSTAMP";
87
88 public static final String SEQUENCE = "SEQUENCE";
89
90 public static final String STATUS = "STATUS";
91
92 public static final String SUMMARY = "SUMMARY";
93
94 public static final String TRANSP = "TRANSP";
95
96 public static final String UID = "UID";
97
98 public static final String URL = "URL";
99
100 public static final String RECURRENCE_ID = "RECURRENCE-ID";
101
102 public static final String COMPLETED = "COMPLETED";
103
104 public static final String DUE = "DUE";
105
106 public static final String FREEBUSY = "FREEBUSY";
107
108 public static final String TZID = "TZID";
109
110 public static final String TZNAME = "TZNAME";
111
112 public static final String TZOFFSETFROM = "TZOFFSETFROM";
113
114 public static final String TZOFFSETTO = "TZOFFSETTO";
115
116 public static final String TZURL = "TZURL";
117
118 public static final String ACTION = "ACTION";
119
120 public static final String REPEAT = "REPEAT";
121
122 public static final String TRIGGER = "TRIGGER";
123
124 public static final String REQUEST_STATUS = "REQUEST-STATUS";
125
126 /***
127 * either 'dtend' or 'duration' may appear in a 'eventprop', but 'dtend' and
128 * 'duration' MUST NOT occur in the same 'eventprop'
129 */
130 public static final String DTEND = "DTEND";
131
132 public static final String DURATION = "DURATION";
133
134 /***
135 * the following are optional, and MAY occur more than once
136 */
137 public static final String ATTACH = "ATTACH";
138
139 public static final String ATTENDEE = "ATTENDEE";
140
141 public static final String CATEGORIES = "CATEGORIES";
142
143 public static final String COMMENT = "COMMENT";
144
145 public static final String CONTACT = "CONTACT";
146
147 public static final String EXDATE = "EXDATE";
148
149 public static final String EXRULE = "EXRULE";
150
151 public static final String RSTATUS = "RSTATUS";
152
153 public static final String RELATED_TO = "RELATED-TO";
154
155 public static final String RESOURCES = "RESOURCES";
156
157 public static final String RDATE = "RDATE";
158
159 public static final String RRULE = "RRULE";
160
161 private String name;
162
163 private ParameterList parameters;
164
165 /***
166 * Constructor.
167 * @param aName
168 * property name
169 * @param aValue
170 * property value
171 */
172 public Property(final String aName) {
173
174 this(aName, null);
175 }
176
177 /***
178 * Constructor made protected to enforce the use of
179 * <code>PropertyFactory</code> for property instantiation.
180 * @param aName
181 * property name
182 * @param aList
183 * a list of parameters
184 * @param aValue
185 * property value
186 */
187 protected Property(final String aName, final ParameterList aList) {
188 this.name = aName;
189 this.parameters = aList;
190 }
191
192 /***
193 * @see java.lang.Object#toString()
194 */
195 public final String toString() {
196
197 if (getParameters() != null) {
198 return getName() + getParameters() + ":" + getValue() + "\r\n";
199 }
200
201 return getName() + ":" + getValue() + "\r\n";
202 }
203
204 /***
205 * Indicates whether this property is a
206 * calendar property
207 * @return boolean
208 */
209 public final boolean isCalendarProperty() {
210
211 return PRODID.equals(getName()) || VERSION.equals(getName())
212 || CALSCALE.equals(getName()) || METHOD.equals(getName());
213 }
214
215 /***
216 * Indicates whether this property is a
217 * component property
218 * @return boolean
219 */
220 public final boolean isComponentProperty() {
221
222 return false;
223 }
224
225 /***
226 * @return Returns the name.
227 */
228 public final String getName() {
229 return name;
230 }
231
232 /***
233 * @return Returns the parameters.
234 */
235 public final ParameterList getParameters() {
236 return parameters;
237 }
238
239 /***
240 * @return Returns the value.
241 */
242 public abstract String getValue();
243
244 /***
245 * Perform validation on a property.
246 *
247 * @throws ValidationException
248 * where the property is not in a valid state
249 */
250 public void validate() throws ValidationException {
251
252 }
253 }