|
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; |
|
33 |
|
34 import java.io.IOException; |
|
35 import java.net.URISyntaxException; |
|
36 import java.text.ParseException; |
|
37 |
|
38 import net.fortuna.ical4j.model.property.Action; |
|
39 import net.fortuna.ical4j.model.property.Attach; |
|
40 import net.fortuna.ical4j.model.property.Attendee; |
|
41 import net.fortuna.ical4j.model.property.CalScale; |
|
42 import net.fortuna.ical4j.model.property.Categories; |
|
43 import net.fortuna.ical4j.model.property.Clazz; |
|
44 import net.fortuna.ical4j.model.property.Comment; |
|
45 import net.fortuna.ical4j.model.property.Completed; |
|
46 import net.fortuna.ical4j.model.property.Contact; |
|
47 import net.fortuna.ical4j.model.property.Country; |
|
48 import net.fortuna.ical4j.model.property.Created; |
|
49 import net.fortuna.ical4j.model.property.Description; |
|
50 import net.fortuna.ical4j.model.property.DtEnd; |
|
51 import net.fortuna.ical4j.model.property.DtStamp; |
|
52 import net.fortuna.ical4j.model.property.DtStart; |
|
53 import net.fortuna.ical4j.model.property.Due; |
|
54 import net.fortuna.ical4j.model.property.Duration; |
|
55 import net.fortuna.ical4j.model.property.ExDate; |
|
56 import net.fortuna.ical4j.model.property.ExRule; |
|
57 import net.fortuna.ical4j.model.property.ExtendedAddress; |
|
58 import net.fortuna.ical4j.model.property.FreeBusy; |
|
59 import net.fortuna.ical4j.model.property.Geo; |
|
60 import net.fortuna.ical4j.model.property.LastModified; |
|
61 import net.fortuna.ical4j.model.property.Locality; |
|
62 import net.fortuna.ical4j.model.property.Location; |
|
63 import net.fortuna.ical4j.model.property.LocationType; |
|
64 import net.fortuna.ical4j.model.property.Method; |
|
65 import net.fortuna.ical4j.model.property.Name; |
|
66 import net.fortuna.ical4j.model.property.Organizer; |
|
67 import net.fortuna.ical4j.model.property.PercentComplete; |
|
68 import net.fortuna.ical4j.model.property.Postalcode; |
|
69 import net.fortuna.ical4j.model.property.Priority; |
|
70 import net.fortuna.ical4j.model.property.ProdId; |
|
71 import net.fortuna.ical4j.model.property.RDate; |
|
72 import net.fortuna.ical4j.model.property.RRule; |
|
73 import net.fortuna.ical4j.model.property.RecurrenceId; |
|
74 import net.fortuna.ical4j.model.property.Region; |
|
75 import net.fortuna.ical4j.model.property.RelatedTo; |
|
76 import net.fortuna.ical4j.model.property.Repeat; |
|
77 import net.fortuna.ical4j.model.property.RequestStatus; |
|
78 import net.fortuna.ical4j.model.property.Resources; |
|
79 import net.fortuna.ical4j.model.property.Sequence; |
|
80 import net.fortuna.ical4j.model.property.Status; |
|
81 import net.fortuna.ical4j.model.property.StreetAddress; |
|
82 import net.fortuna.ical4j.model.property.Summary; |
|
83 import net.fortuna.ical4j.model.property.Tel; |
|
84 import net.fortuna.ical4j.model.property.Transp; |
|
85 import net.fortuna.ical4j.model.property.Trigger; |
|
86 import net.fortuna.ical4j.model.property.TzId; |
|
87 import net.fortuna.ical4j.model.property.TzName; |
|
88 import net.fortuna.ical4j.model.property.TzOffsetFrom; |
|
89 import net.fortuna.ical4j.model.property.TzOffsetTo; |
|
90 import net.fortuna.ical4j.model.property.TzUrl; |
|
91 import net.fortuna.ical4j.model.property.Uid; |
|
92 import net.fortuna.ical4j.model.property.Url; |
|
93 import net.fortuna.ical4j.model.property.Version; |
|
94 import net.fortuna.ical4j.model.property.XProperty; |
|
95 |
|
96 /** |
|
97 * A factory for creating iCalendar properties. Note that if relaxed parsing is enabled (via specifying the system |
|
98 * property: icalj.parsing.relaxed=true) illegal property names are allowed. |
|
99 * |
|
100 * @author Ben Fortuna |
|
101 * |
|
102 * $Id$ [05-Apr-2004] |
|
103 */ |
|
104 public class PropertyFactoryImpl extends AbstractContentFactory implements PropertyFactory { |
|
105 |
|
106 private static final long serialVersionUID = -7174232004486979641L; |
|
107 |
|
108 private static PropertyFactoryImpl instance = new PropertyFactoryImpl(); |
|
109 |
|
110 /** |
|
111 * Constructor made private to prevent instantiation. |
|
112 */ |
|
113 protected PropertyFactoryImpl() { |
|
114 registerDefaultFactory(Property.ACTION, new ActionFactory()); |
|
115 registerDefaultFactory(Property.ATTACH, new AttachFactory()); |
|
116 registerDefaultFactory(Property.ATTENDEE, new AttendeeFactory()); |
|
117 registerDefaultFactory(Property.CALSCALE, new CalScaleFactory()); |
|
118 registerDefaultFactory(Property.CATEGORIES, new CategoriesFactory()); |
|
119 registerDefaultFactory(Property.CLASS, new ClazzFactory()); |
|
120 registerDefaultFactory(Property.COMMENT, new CommentFactory()); |
|
121 registerDefaultFactory(Property.COMPLETED, new CompletedFactory()); |
|
122 registerDefaultFactory(Property.CONTACT, new ContactFactory()); |
|
123 registerDefaultFactory(Property.COUNTRY, new CountryFactory()); |
|
124 registerDefaultFactory(Property.CREATED, new CreatedFactory()); |
|
125 registerDefaultFactory(Property.DESCRIPTION, new DescriptionFactory()); |
|
126 registerDefaultFactory(Property.DTEND, new DtEndFactory()); |
|
127 registerDefaultFactory(Property.DTSTAMP, new DtStampFactory()); |
|
128 registerDefaultFactory(Property.DTSTART, new DtStartFactory()); |
|
129 registerDefaultFactory(Property.DUE, new DueFactory()); |
|
130 registerDefaultFactory(Property.DURATION, new DurationFactory()); |
|
131 registerDefaultFactory(Property.EXDATE, new ExDateFactory()); |
|
132 registerDefaultFactory(Property.EXRULE, new ExRuleFactory()); |
|
133 registerDefaultFactory(Property.EXTENDED_ADDRESS, new ExtendedAddressFactory()); |
|
134 registerDefaultFactory(Property.FREEBUSY, new FreeBusyFactory()); |
|
135 registerDefaultFactory(Property.GEO, new GeoFactory()); |
|
136 registerDefaultFactory(Property.LAST_MODIFIED, new LastModifiedFactory()); |
|
137 registerDefaultFactory(Property.LOCALITY, new LocalityFactory()); |
|
138 registerDefaultFactory(Property.LOCATION, new LocationFactory()); |
|
139 registerDefaultFactory(Property.LOCATION_TYPE, new LocationTypeFactory()); |
|
140 registerDefaultFactory(Property.METHOD, new MethodFactory()); |
|
141 registerDefaultFactory(Property.NAME, new NameFactory()); |
|
142 registerDefaultFactory(Property.ORGANIZER, new OrganizerFactory()); |
|
143 registerDefaultFactory(Property.PERCENT_COMPLETE, new PercentCompleteFactory()); |
|
144 registerDefaultFactory(Property.POSTALCODE, new PostalcodeFactory()); |
|
145 registerDefaultFactory(Property.PRIORITY, new PriorityFactory()); |
|
146 registerDefaultFactory(Property.PRODID, new ProdIdFactory()); |
|
147 registerDefaultFactory(Property.RDATE, new RDateFactory()); |
|
148 registerDefaultFactory(Property.RECURRENCE_ID, new RecurrenceIdFactory()); |
|
149 registerDefaultFactory(Property.REGION, new RegionFactory()); |
|
150 registerDefaultFactory(Property.RELATED_TO, new RelatedToFactory()); |
|
151 registerDefaultFactory(Property.REPEAT, new RepeatFactory()); |
|
152 registerDefaultFactory(Property.REQUEST_STATUS, new RequestStatusFactory()); |
|
153 registerDefaultFactory(Property.RESOURCES, new ResourcesFactory()); |
|
154 registerDefaultFactory(Property.RRULE, new RRuleFactory()); |
|
155 registerDefaultFactory(Property.SEQUENCE, new SequenceFactory()); |
|
156 registerDefaultFactory(Property.STATUS, new StatusFactory()); |
|
157 registerDefaultFactory(Property.STREET_ADDRESS, new StreetAddressFactory()); |
|
158 registerDefaultFactory(Property.SUMMARY, new SummaryFactory()); |
|
159 registerDefaultFactory(Property.TEL, new TelFactory()); |
|
160 registerDefaultFactory(Property.TRANSP, new TranspFactory()); |
|
161 registerDefaultFactory(Property.TRIGGER, new TriggerFactory()); |
|
162 registerDefaultFactory(Property.TZID, new TzIdFactory()); |
|
163 registerDefaultFactory(Property.TZNAME, new TzNameFactory()); |
|
164 registerDefaultFactory(Property.TZOFFSETFROM, new TzOffsetFromFactory()); |
|
165 registerDefaultFactory(Property.TZOFFSETTO, new TzOffsetToFactory()); |
|
166 registerDefaultFactory(Property.TZURL, new TzUrlFactory()); |
|
167 registerDefaultFactory(Property.UID, new UidFactory()); |
|
168 registerDefaultFactory(Property.URL, new UrlFactory()); |
|
169 registerDefaultFactory(Property.VERSION, new VersionFactory()); |
|
170 } |
|
171 |
|
172 private static class ActionFactory implements PropertyFactory { |
|
173 private static final long serialVersionUID = 1L; |
|
174 |
|
175 public Property createProperty(final String name, |
|
176 final ParameterList parameters, final String value) |
|
177 throws IOException, URISyntaxException, ParseException { |
|
178 return new Action(parameters, value); |
|
179 } |
|
180 |
|
181 public Property createProperty(final String name) { |
|
182 return new Action(); |
|
183 } |
|
184 } |
|
185 |
|
186 private static class AttachFactory implements PropertyFactory { |
|
187 private static final long serialVersionUID = 1L; |
|
188 |
|
189 public Property createProperty(final String name, |
|
190 final ParameterList parameters, final String value) |
|
191 throws IOException, URISyntaxException, ParseException { |
|
192 return new Attach(parameters, value); |
|
193 } |
|
194 |
|
195 public Property createProperty(final String name) { |
|
196 return new Attach(); |
|
197 } |
|
198 } |
|
199 |
|
200 private static class AttendeeFactory implements PropertyFactory { |
|
201 private static final long serialVersionUID = 1L; |
|
202 |
|
203 public Property createProperty(final String name, |
|
204 final ParameterList parameters, final String value) |
|
205 throws IOException, URISyntaxException, ParseException { |
|
206 return new Attendee(parameters, value); |
|
207 } |
|
208 |
|
209 public Property createProperty(final String name) { |
|
210 return new Attendee(); |
|
211 } |
|
212 } |
|
213 |
|
214 private static class CalScaleFactory implements PropertyFactory { |
|
215 private static final long serialVersionUID = 1L; |
|
216 |
|
217 public Property createProperty(final String name, |
|
218 final ParameterList parameters, final String value) |
|
219 throws IOException, URISyntaxException, ParseException { |
|
220 return new CalScale(parameters, value); |
|
221 } |
|
222 |
|
223 public Property createProperty(final String name) { |
|
224 return new CalScale(); |
|
225 } |
|
226 } |
|
227 |
|
228 private static class CategoriesFactory implements PropertyFactory { |
|
229 private static final long serialVersionUID = 1L; |
|
230 |
|
231 public Property createProperty(final String name, |
|
232 final ParameterList parameters, final String value) |
|
233 throws IOException, URISyntaxException, ParseException { |
|
234 return new Categories(parameters, value); |
|
235 } |
|
236 |
|
237 public Property createProperty(final String name) { |
|
238 return new Categories(); |
|
239 } |
|
240 } |
|
241 |
|
242 private static class ClazzFactory implements PropertyFactory { |
|
243 private static final long serialVersionUID = 1L; |
|
244 |
|
245 public Property createProperty(final String name, |
|
246 final ParameterList parameters, final String value) |
|
247 throws IOException, URISyntaxException, ParseException { |
|
248 return new Clazz(parameters, value); |
|
249 } |
|
250 |
|
251 public Property createProperty(final String name) { |
|
252 return new Clazz(); |
|
253 } |
|
254 } |
|
255 |
|
256 private static class CommentFactory implements PropertyFactory { |
|
257 private static final long serialVersionUID = 1L; |
|
258 |
|
259 public Property createProperty(final String name, |
|
260 final ParameterList parameters, final String value) |
|
261 throws IOException, URISyntaxException, ParseException { |
|
262 return new Comment(parameters, value); |
|
263 } |
|
264 |
|
265 public Property createProperty(final String name) { |
|
266 return new Comment(); |
|
267 } |
|
268 } |
|
269 |
|
270 private static class CompletedFactory implements PropertyFactory { |
|
271 private static final long serialVersionUID = 1L; |
|
272 |
|
273 public Property createProperty(final String name, |
|
274 final ParameterList parameters, final String value) |
|
275 throws IOException, URISyntaxException, ParseException { |
|
276 return new Completed(parameters, value); |
|
277 } |
|
278 |
|
279 public Property createProperty(final String name) { |
|
280 return new Completed(); |
|
281 } |
|
282 } |
|
283 |
|
284 private static class ContactFactory implements PropertyFactory { |
|
285 private static final long serialVersionUID = 1L; |
|
286 |
|
287 public Property createProperty(final String name, |
|
288 final ParameterList parameters, final String value) |
|
289 throws IOException, URISyntaxException, ParseException { |
|
290 return new Contact(parameters, value); |
|
291 } |
|
292 |
|
293 public Property createProperty(final String name) { |
|
294 return new Contact(); |
|
295 } |
|
296 } |
|
297 |
|
298 private static class CountryFactory implements PropertyFactory { |
|
299 private static final long serialVersionUID = 1L; |
|
300 |
|
301 public Property createProperty(final String name, |
|
302 final ParameterList parameters, final String value) |
|
303 throws IOException, URISyntaxException, ParseException { |
|
304 return new Country(parameters, value); |
|
305 } |
|
306 |
|
307 public Property createProperty(final String name) { |
|
308 return new Country(); |
|
309 } |
|
310 } |
|
311 |
|
312 private static class CreatedFactory implements PropertyFactory { |
|
313 private static final long serialVersionUID = 1L; |
|
314 |
|
315 public Property createProperty(final String name, |
|
316 final ParameterList parameters, final String value) |
|
317 throws IOException, URISyntaxException, ParseException { |
|
318 return new Created(parameters, value); |
|
319 } |
|
320 |
|
321 public Property createProperty(final String name) { |
|
322 return new Created(); |
|
323 } |
|
324 } |
|
325 |
|
326 private static class DescriptionFactory implements PropertyFactory { |
|
327 private static final long serialVersionUID = 1L; |
|
328 |
|
329 public Property createProperty(final String name, |
|
330 final ParameterList parameters, final String value) |
|
331 throws IOException, URISyntaxException, ParseException { |
|
332 return new Description(parameters, value); |
|
333 } |
|
334 |
|
335 public Property createProperty(final String name) { |
|
336 return new Description(); |
|
337 } |
|
338 } |
|
339 |
|
340 private static class DtEndFactory implements PropertyFactory { |
|
341 private static final long serialVersionUID = 1L; |
|
342 |
|
343 public Property createProperty(final String name, |
|
344 final ParameterList parameters, final String value) |
|
345 throws IOException, URISyntaxException, ParseException { |
|
346 return new DtEnd(parameters, value); |
|
347 } |
|
348 |
|
349 public Property createProperty(final String name) { |
|
350 return new DtEnd(); |
|
351 } |
|
352 } |
|
353 |
|
354 private static class DtStampFactory implements PropertyFactory { |
|
355 private static final long serialVersionUID = 1L; |
|
356 |
|
357 public Property createProperty(final String name, |
|
358 final ParameterList parameters, final String value) |
|
359 throws IOException, URISyntaxException, ParseException { |
|
360 return new DtStamp(parameters, value); |
|
361 } |
|
362 |
|
363 public Property createProperty(final String name) { |
|
364 return new DtStamp(); |
|
365 } |
|
366 } |
|
367 |
|
368 /** |
|
369 * @return |
|
370 */ |
|
371 private static class DtStartFactory implements PropertyFactory { |
|
372 private static final long serialVersionUID = 1L; |
|
373 |
|
374 public Property createProperty(final String name, |
|
375 final ParameterList parameters, final String value) |
|
376 throws IOException, URISyntaxException, ParseException { |
|
377 return new DtStart(parameters, value); |
|
378 } |
|
379 |
|
380 public Property createProperty(final String name) { |
|
381 return new DtStart(); |
|
382 } |
|
383 } |
|
384 |
|
385 private static class DueFactory implements PropertyFactory { |
|
386 private static final long serialVersionUID = 1L; |
|
387 |
|
388 public Property createProperty(final String name, |
|
389 final ParameterList parameters, final String value) |
|
390 throws IOException, URISyntaxException, ParseException { |
|
391 return new Due(parameters, value); |
|
392 } |
|
393 |
|
394 public Property createProperty(final String name) { |
|
395 return new Due(); |
|
396 } |
|
397 } |
|
398 |
|
399 private static class DurationFactory implements PropertyFactory { |
|
400 private static final long serialVersionUID = 1L; |
|
401 |
|
402 public Property createProperty(final String name, |
|
403 final ParameterList parameters, final String value) |
|
404 throws IOException, URISyntaxException, ParseException { |
|
405 return new Duration(parameters, value); |
|
406 } |
|
407 |
|
408 public Property createProperty(final String name) { |
|
409 return new Duration(); |
|
410 } |
|
411 } |
|
412 |
|
413 private static class ExDateFactory implements PropertyFactory { |
|
414 private static final long serialVersionUID = 1L; |
|
415 |
|
416 public Property createProperty(final String name, |
|
417 final ParameterList parameters, final String value) |
|
418 throws IOException, URISyntaxException, ParseException { |
|
419 return new ExDate(parameters, value); |
|
420 } |
|
421 |
|
422 public Property createProperty(final String name) { |
|
423 return new ExDate(); |
|
424 } |
|
425 } |
|
426 |
|
427 private static class ExRuleFactory implements PropertyFactory { |
|
428 private static final long serialVersionUID = 1L; |
|
429 |
|
430 public Property createProperty(final String name, |
|
431 final ParameterList parameters, final String value) |
|
432 throws IOException, URISyntaxException, ParseException { |
|
433 return new ExRule(parameters, value); |
|
434 } |
|
435 |
|
436 public Property createProperty(final String name) { |
|
437 return new ExRule(); |
|
438 } |
|
439 } |
|
440 |
|
441 private static class ExtendedAddressFactory implements PropertyFactory { |
|
442 private static final long serialVersionUID = 1L; |
|
443 |
|
444 public Property createProperty(final String name, |
|
445 final ParameterList parameters, final String value) |
|
446 throws IOException, URISyntaxException, ParseException { |
|
447 return new ExtendedAddress(parameters, value); |
|
448 } |
|
449 |
|
450 public Property createProperty(final String name) { |
|
451 return new ExtendedAddress(); |
|
452 } |
|
453 } |
|
454 |
|
455 private static class FreeBusyFactory implements PropertyFactory { |
|
456 private static final long serialVersionUID = 1L; |
|
457 |
|
458 public Property createProperty(final String name, |
|
459 final ParameterList parameters, final String value) |
|
460 throws IOException, URISyntaxException, ParseException { |
|
461 return new FreeBusy(parameters, value); |
|
462 } |
|
463 |
|
464 public Property createProperty(final String name) { |
|
465 return new FreeBusy(); |
|
466 } |
|
467 } |
|
468 |
|
469 private static class GeoFactory implements PropertyFactory { |
|
470 private static final long serialVersionUID = 1L; |
|
471 |
|
472 public Property createProperty(final String name, |
|
473 final ParameterList parameters, final String value) |
|
474 throws IOException, URISyntaxException, ParseException { |
|
475 return new Geo(parameters, value); |
|
476 } |
|
477 |
|
478 public Property createProperty(final String name) { |
|
479 return new Geo(); |
|
480 } |
|
481 } |
|
482 |
|
483 private static class LastModifiedFactory implements PropertyFactory { |
|
484 private static final long serialVersionUID = 1L; |
|
485 |
|
486 public Property createProperty(final String name, |
|
487 final ParameterList parameters, final String value) |
|
488 throws IOException, URISyntaxException, ParseException { |
|
489 return new LastModified(parameters, value); |
|
490 } |
|
491 |
|
492 public Property createProperty(final String name) { |
|
493 return new LastModified(); |
|
494 } |
|
495 } |
|
496 |
|
497 private static class LocalityFactory implements PropertyFactory { |
|
498 private static final long serialVersionUID = 1L; |
|
499 |
|
500 public Property createProperty(final String name, |
|
501 final ParameterList parameters, final String value) |
|
502 throws IOException, URISyntaxException, ParseException { |
|
503 return new Locality(parameters, value); |
|
504 } |
|
505 |
|
506 public Property createProperty(final String name) { |
|
507 return new Locality(); |
|
508 } |
|
509 } |
|
510 |
|
511 private static class LocationFactory implements PropertyFactory { |
|
512 private static final long serialVersionUID = 1L; |
|
513 |
|
514 public Property createProperty(final String name, |
|
515 final ParameterList parameters, final String value) |
|
516 throws IOException, URISyntaxException, ParseException { |
|
517 return new Location(parameters, value); |
|
518 } |
|
519 |
|
520 public Property createProperty(final String name) { |
|
521 return new Location(); |
|
522 } |
|
523 } |
|
524 |
|
525 private static class LocationTypeFactory implements PropertyFactory { |
|
526 private static final long serialVersionUID = 1L; |
|
527 |
|
528 public Property createProperty(final String name, |
|
529 final ParameterList parameters, final String value) |
|
530 throws IOException, URISyntaxException, ParseException { |
|
531 return new LocationType(parameters, value); |
|
532 } |
|
533 |
|
534 public Property createProperty(final String name) { |
|
535 return new LocationType(); |
|
536 } |
|
537 } |
|
538 |
|
539 private static class MethodFactory implements PropertyFactory { |
|
540 private static final long serialVersionUID = 1L; |
|
541 |
|
542 public Property createProperty(final String name, |
|
543 final ParameterList parameters, final String value) |
|
544 throws IOException, URISyntaxException, ParseException { |
|
545 return new Method(parameters, value); |
|
546 } |
|
547 |
|
548 public Property createProperty(final String name) { |
|
549 return new Method(); |
|
550 } |
|
551 } |
|
552 |
|
553 private static class NameFactory implements PropertyFactory { |
|
554 private static final long serialVersionUID = 1L; |
|
555 |
|
556 public Property createProperty(final String name, |
|
557 final ParameterList parameters, final String value) |
|
558 throws IOException, URISyntaxException, ParseException { |
|
559 return new Name(parameters, value); |
|
560 } |
|
561 |
|
562 public Property createProperty(final String name) { |
|
563 return new Name(); |
|
564 } |
|
565 } |
|
566 |
|
567 private static class OrganizerFactory implements PropertyFactory { |
|
568 private static final long serialVersionUID = 1L; |
|
569 |
|
570 public Property createProperty(final String name, |
|
571 final ParameterList parameters, final String value) |
|
572 throws IOException, URISyntaxException, ParseException { |
|
573 return new Organizer(parameters, value); |
|
574 } |
|
575 |
|
576 public Property createProperty(final String name) { |
|
577 return new Organizer(); |
|
578 } |
|
579 } |
|
580 |
|
581 private static class PercentCompleteFactory implements PropertyFactory { |
|
582 private static final long serialVersionUID = 1L; |
|
583 |
|
584 public Property createProperty(final String name, |
|
585 final ParameterList parameters, final String value) |
|
586 throws IOException, URISyntaxException, ParseException { |
|
587 return new PercentComplete(parameters, value); |
|
588 } |
|
589 |
|
590 public Property createProperty(final String name) { |
|
591 return new PercentComplete(); |
|
592 } |
|
593 } |
|
594 |
|
595 private static class PostalcodeFactory implements PropertyFactory { |
|
596 private static final long serialVersionUID = 1L; |
|
597 |
|
598 public Property createProperty(final String name, |
|
599 final ParameterList parameters, final String value) |
|
600 throws IOException, URISyntaxException, ParseException { |
|
601 return new Postalcode(parameters, value); |
|
602 } |
|
603 |
|
604 public Property createProperty(final String name) { |
|
605 return new Postalcode(); |
|
606 } |
|
607 } |
|
608 |
|
609 private static class PriorityFactory implements PropertyFactory { |
|
610 private static final long serialVersionUID = 1L; |
|
611 |
|
612 public Property createProperty(final String name, |
|
613 final ParameterList parameters, final String value) |
|
614 throws IOException, URISyntaxException, ParseException { |
|
615 return new Priority(parameters, value); |
|
616 } |
|
617 |
|
618 public Property createProperty(final String name) { |
|
619 return new Priority(); |
|
620 } |
|
621 } |
|
622 |
|
623 private static class ProdIdFactory implements PropertyFactory { |
|
624 private static final long serialVersionUID = 1L; |
|
625 |
|
626 public Property createProperty(final String name, |
|
627 final ParameterList parameters, final String value) |
|
628 throws IOException, URISyntaxException, ParseException { |
|
629 return new ProdId(parameters, value); |
|
630 } |
|
631 |
|
632 public Property createProperty(final String name) { |
|
633 return new ProdId(); |
|
634 } |
|
635 } |
|
636 |
|
637 private static class RDateFactory implements PropertyFactory { |
|
638 private static final long serialVersionUID = 1L; |
|
639 |
|
640 public Property createProperty(final String name, |
|
641 final ParameterList parameters, final String value) |
|
642 throws IOException, URISyntaxException, ParseException { |
|
643 return new RDate(parameters, value); |
|
644 } |
|
645 |
|
646 public Property createProperty(final String name) { |
|
647 return new RDate(); |
|
648 } |
|
649 } |
|
650 |
|
651 private static class RecurrenceIdFactory implements PropertyFactory { |
|
652 private static final long serialVersionUID = 1L; |
|
653 |
|
654 public Property createProperty(final String name, |
|
655 final ParameterList parameters, final String value) |
|
656 throws IOException, URISyntaxException, ParseException { |
|
657 return new RecurrenceId(parameters, value); |
|
658 } |
|
659 |
|
660 public Property createProperty(final String name) { |
|
661 return new RecurrenceId(); |
|
662 } |
|
663 } |
|
664 |
|
665 private static class RegionFactory implements PropertyFactory { |
|
666 private static final long serialVersionUID = 1L; |
|
667 |
|
668 public Property createProperty(final String name, |
|
669 final ParameterList parameters, final String value) |
|
670 throws IOException, URISyntaxException, ParseException { |
|
671 return new Region(parameters, value); |
|
672 } |
|
673 |
|
674 public Property createProperty(final String name) { |
|
675 return new Region(); |
|
676 } |
|
677 } |
|
678 |
|
679 private static class RelatedToFactory implements PropertyFactory { |
|
680 private static final long serialVersionUID = 1L; |
|
681 |
|
682 public Property createProperty(final String name, |
|
683 final ParameterList parameters, final String value) |
|
684 throws IOException, URISyntaxException, ParseException { |
|
685 return new RelatedTo(parameters, value); |
|
686 } |
|
687 |
|
688 public Property createProperty(final String name) { |
|
689 return new RelatedTo(); |
|
690 } |
|
691 } |
|
692 |
|
693 private static class RepeatFactory implements PropertyFactory { |
|
694 private static final long serialVersionUID = 1L; |
|
695 |
|
696 public Property createProperty(final String name, |
|
697 final ParameterList parameters, final String value) |
|
698 throws IOException, URISyntaxException, ParseException { |
|
699 return new Repeat(parameters, value); |
|
700 } |
|
701 |
|
702 public Property createProperty(final String name) { |
|
703 return new Repeat(); |
|
704 } |
|
705 } |
|
706 |
|
707 private static class RequestStatusFactory implements PropertyFactory { |
|
708 private static final long serialVersionUID = 1L; |
|
709 |
|
710 public Property createProperty(final String name, |
|
711 final ParameterList parameters, final String value) |
|
712 throws IOException, URISyntaxException, ParseException { |
|
713 return new RequestStatus(parameters, value); |
|
714 } |
|
715 |
|
716 public Property createProperty(final String name) { |
|
717 return new RequestStatus(); |
|
718 } |
|
719 } |
|
720 |
|
721 private static class ResourcesFactory implements PropertyFactory { |
|
722 private static final long serialVersionUID = 1L; |
|
723 |
|
724 public Property createProperty(final String name, |
|
725 final ParameterList parameters, final String value) |
|
726 throws IOException, URISyntaxException, ParseException { |
|
727 return new Resources(parameters, value); |
|
728 } |
|
729 |
|
730 public Property createProperty(final String name) { |
|
731 return new Resources(); |
|
732 } |
|
733 } |
|
734 |
|
735 private static class RRuleFactory implements PropertyFactory { |
|
736 private static final long serialVersionUID = 1L; |
|
737 |
|
738 public Property createProperty(final String name, |
|
739 final ParameterList parameters, final String value) |
|
740 throws IOException, URISyntaxException, ParseException { |
|
741 return new RRule(parameters, value); |
|
742 } |
|
743 |
|
744 public Property createProperty(final String name) { |
|
745 return new RRule(); |
|
746 } |
|
747 } |
|
748 |
|
749 private static class SequenceFactory implements PropertyFactory { |
|
750 private static final long serialVersionUID = 1L; |
|
751 |
|
752 public Property createProperty(final String name, |
|
753 final ParameterList parameters, final String value) |
|
754 throws IOException, URISyntaxException, ParseException { |
|
755 return new Sequence(parameters, value); |
|
756 } |
|
757 |
|
758 public Property createProperty(final String name) { |
|
759 return new Sequence(); |
|
760 } |
|
761 } |
|
762 |
|
763 private static class StatusFactory implements PropertyFactory { |
|
764 private static final long serialVersionUID = 1L; |
|
765 |
|
766 public Property createProperty(final String name, |
|
767 final ParameterList parameters, final String value) |
|
768 throws IOException, URISyntaxException, ParseException { |
|
769 return new Status(parameters, value); |
|
770 } |
|
771 |
|
772 public Property createProperty(final String name) { |
|
773 return new Status(); |
|
774 } |
|
775 } |
|
776 |
|
777 private static class StreetAddressFactory implements PropertyFactory { |
|
778 private static final long serialVersionUID = 1L; |
|
779 |
|
780 public Property createProperty(final String name, |
|
781 final ParameterList parameters, final String value) |
|
782 throws IOException, URISyntaxException, ParseException { |
|
783 return new StreetAddress(parameters, value); |
|
784 } |
|
785 |
|
786 public Property createProperty(final String name) { |
|
787 return new StreetAddress(); |
|
788 } |
|
789 } |
|
790 |
|
791 private static class SummaryFactory implements PropertyFactory { |
|
792 private static final long serialVersionUID = 1L; |
|
793 |
|
794 public Property createProperty(final String name, |
|
795 final ParameterList parameters, final String value) |
|
796 throws IOException, URISyntaxException, ParseException { |
|
797 return new Summary(parameters, value); |
|
798 } |
|
799 |
|
800 public Property createProperty(final String name) { |
|
801 return new Summary(); |
|
802 } |
|
803 } |
|
804 |
|
805 private static class TelFactory implements PropertyFactory { |
|
806 private static final long serialVersionUID = 1L; |
|
807 |
|
808 public Property createProperty(final String name, |
|
809 final ParameterList parameters, final String value) |
|
810 throws IOException, URISyntaxException, ParseException { |
|
811 return new Tel(parameters, value); |
|
812 } |
|
813 |
|
814 public Property createProperty(final String name) { |
|
815 return new Tel(); |
|
816 } |
|
817 } |
|
818 |
|
819 private static class TranspFactory implements PropertyFactory { |
|
820 private static final long serialVersionUID = 1L; |
|
821 |
|
822 public Property createProperty(final String name, |
|
823 final ParameterList parameters, final String value) |
|
824 throws IOException, URISyntaxException, ParseException { |
|
825 return new Transp(parameters, value); |
|
826 } |
|
827 |
|
828 public Property createProperty(final String name) { |
|
829 return new Transp(); |
|
830 } |
|
831 } |
|
832 |
|
833 private static class TriggerFactory implements PropertyFactory { |
|
834 private static final long serialVersionUID = 1L; |
|
835 |
|
836 public Property createProperty(final String name, |
|
837 final ParameterList parameters, final String value) |
|
838 throws IOException, URISyntaxException, ParseException { |
|
839 return new Trigger(parameters, value); |
|
840 } |
|
841 |
|
842 public Property createProperty(final String name) { |
|
843 return new Trigger(); |
|
844 } |
|
845 } |
|
846 |
|
847 private static class TzIdFactory implements PropertyFactory { |
|
848 private static final long serialVersionUID = 1L; |
|
849 |
|
850 public Property createProperty(final String name, |
|
851 final ParameterList parameters, final String value) |
|
852 throws IOException, URISyntaxException, ParseException { |
|
853 return new TzId(parameters, value); |
|
854 } |
|
855 |
|
856 public Property createProperty(final String name) { |
|
857 return new TzId(); |
|
858 } |
|
859 } |
|
860 |
|
861 private static class TzNameFactory implements PropertyFactory { |
|
862 private static final long serialVersionUID = 1L; |
|
863 |
|
864 public Property createProperty(final String name, |
|
865 final ParameterList parameters, final String value) |
|
866 throws IOException, URISyntaxException, ParseException { |
|
867 return new TzName(parameters, value); |
|
868 } |
|
869 |
|
870 public Property createProperty(final String name) { |
|
871 return new TzName(); |
|
872 } |
|
873 } |
|
874 |
|
875 private static class TzOffsetFromFactory implements PropertyFactory { |
|
876 private static final long serialVersionUID = 1L; |
|
877 |
|
878 public Property createProperty(final String name, |
|
879 final ParameterList parameters, final String value) |
|
880 throws IOException, URISyntaxException, ParseException { |
|
881 return new TzOffsetFrom(parameters, value); |
|
882 } |
|
883 |
|
884 public Property createProperty(final String name) { |
|
885 return new TzOffsetFrom(); |
|
886 } |
|
887 } |
|
888 |
|
889 private static class TzOffsetToFactory implements PropertyFactory { |
|
890 private static final long serialVersionUID = 1L; |
|
891 |
|
892 public Property createProperty(final String name, |
|
893 final ParameterList parameters, final String value) |
|
894 throws IOException, URISyntaxException, ParseException { |
|
895 return new TzOffsetTo(parameters, value); |
|
896 } |
|
897 |
|
898 public Property createProperty(final String name) { |
|
899 return new TzOffsetTo(); |
|
900 } |
|
901 } |
|
902 |
|
903 private static class TzUrlFactory implements PropertyFactory { |
|
904 private static final long serialVersionUID = 1L; |
|
905 |
|
906 public Property createProperty(final String name, |
|
907 final ParameterList parameters, final String value) |
|
908 throws IOException, URISyntaxException, ParseException { |
|
909 return new TzUrl(parameters, value); |
|
910 } |
|
911 |
|
912 public Property createProperty(final String name) { |
|
913 return new TzUrl(); |
|
914 } |
|
915 } |
|
916 |
|
917 private static class UidFactory implements PropertyFactory { |
|
918 private static final long serialVersionUID = 1L; |
|
919 |
|
920 public Property createProperty(final String name, |
|
921 final ParameterList parameters, final String value) |
|
922 throws IOException, URISyntaxException, ParseException { |
|
923 return new Uid(parameters, value); |
|
924 } |
|
925 |
|
926 public Property createProperty(final String name) { |
|
927 return new Uid(); |
|
928 } |
|
929 } |
|
930 |
|
931 private static class UrlFactory implements PropertyFactory { |
|
932 private static final long serialVersionUID = 1L; |
|
933 |
|
934 public Property createProperty(final String name, |
|
935 final ParameterList parameters, final String value) |
|
936 throws IOException, URISyntaxException, ParseException { |
|
937 return new Url(parameters, value); |
|
938 } |
|
939 |
|
940 public Property createProperty(final String name) { |
|
941 return new Url(); |
|
942 } |
|
943 } |
|
944 |
|
945 private static class VersionFactory implements PropertyFactory { |
|
946 private static final long serialVersionUID = 1L; |
|
947 |
|
948 public Property createProperty(final String name, |
|
949 final ParameterList parameters, final String value) |
|
950 throws IOException, URISyntaxException, ParseException { |
|
951 return new Version(parameters, value); |
|
952 } |
|
953 |
|
954 public Property createProperty(final String name) { |
|
955 return new Version(); |
|
956 } |
|
957 } |
|
958 |
|
959 /** |
|
960 * @return Returns the instance. |
|
961 */ |
|
962 public static PropertyFactoryImpl getInstance() { |
|
963 return instance; |
|
964 } |
|
965 |
|
966 /** |
|
967 * {@inheritDoc} |
|
968 */ |
|
969 public Property createProperty(final String name) { |
|
970 final PropertyFactory factory = (PropertyFactory) getFactory(name); |
|
971 if (factory != null) { |
|
972 return factory.createProperty(name); |
|
973 } |
|
974 else if (isExperimentalName(name)) { |
|
975 return new XProperty(name); |
|
976 } |
|
977 else if (allowIllegalNames()) { |
|
978 return new XProperty(name); |
|
979 } |
|
980 else { |
|
981 throw new IllegalArgumentException("Illegal property [" + name |
|
982 + "]"); |
|
983 } |
|
984 } |
|
985 |
|
986 /** |
|
987 * {@inheritDoc} |
|
988 */ |
|
989 public Property createProperty(final String name, |
|
990 final ParameterList parameters, final String value) |
|
991 throws IOException, URISyntaxException, ParseException { |
|
992 |
|
993 final PropertyFactory factory = (PropertyFactory) getFactory(name); |
|
994 if (factory != null) { |
|
995 return factory.createProperty(name, parameters, value); |
|
996 } |
|
997 else if (isExperimentalName(name)) { |
|
998 return new XProperty(name, parameters, value); |
|
999 } |
|
1000 else if (allowIllegalNames()) { |
|
1001 return new XProperty(name, parameters, value); |
|
1002 } |
|
1003 else { |
|
1004 throw new IllegalArgumentException("Illegal property [" + name |
|
1005 + "]"); |
|
1006 } |
|
1007 } |
|
1008 |
|
1009 /** |
|
1010 * @param name |
|
1011 * @return |
|
1012 */ |
|
1013 private boolean isExperimentalName(final String name) { |
|
1014 return name.startsWith(Property.EXPERIMENTAL_PREFIX) |
|
1015 && name.length() > Property.EXPERIMENTAL_PREFIX.length(); |
|
1016 } |
|
1017 } |