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 private static class DtStartFactory implements PropertyFactory { |
|
369 private static final long serialVersionUID = 1L; |
|
370 |
|
371 public Property createProperty(final String name, |
|
372 final ParameterList parameters, final String value) |
|
373 throws IOException, URISyntaxException, ParseException { |
|
374 return new DtStart(parameters, value); |
|
375 } |
|
376 |
|
377 public Property createProperty(final String name) { |
|
378 return new DtStart(); |
|
379 } |
|
380 } |
|
381 |
|
382 private static class DueFactory implements PropertyFactory { |
|
383 private static final long serialVersionUID = 1L; |
|
384 |
|
385 public Property createProperty(final String name, |
|
386 final ParameterList parameters, final String value) |
|
387 throws IOException, URISyntaxException, ParseException { |
|
388 return new Due(parameters, value); |
|
389 } |
|
390 |
|
391 public Property createProperty(final String name) { |
|
392 return new Due(); |
|
393 } |
|
394 } |
|
395 |
|
396 private static class DurationFactory implements PropertyFactory { |
|
397 private static final long serialVersionUID = 1L; |
|
398 |
|
399 public Property createProperty(final String name, |
|
400 final ParameterList parameters, final String value) |
|
401 throws IOException, URISyntaxException, ParseException { |
|
402 return new Duration(parameters, value); |
|
403 } |
|
404 |
|
405 public Property createProperty(final String name) { |
|
406 return new Duration(); |
|
407 } |
|
408 } |
|
409 |
|
410 private static class ExDateFactory implements PropertyFactory { |
|
411 private static final long serialVersionUID = 1L; |
|
412 |
|
413 public Property createProperty(final String name, |
|
414 final ParameterList parameters, final String value) |
|
415 throws IOException, URISyntaxException, ParseException { |
|
416 return new ExDate(parameters, value); |
|
417 } |
|
418 |
|
419 public Property createProperty(final String name) { |
|
420 return new ExDate(); |
|
421 } |
|
422 } |
|
423 |
|
424 private static class ExRuleFactory implements PropertyFactory { |
|
425 private static final long serialVersionUID = 1L; |
|
426 |
|
427 public Property createProperty(final String name, |
|
428 final ParameterList parameters, final String value) |
|
429 throws IOException, URISyntaxException, ParseException { |
|
430 return new ExRule(parameters, value); |
|
431 } |
|
432 |
|
433 public Property createProperty(final String name) { |
|
434 return new ExRule(); |
|
435 } |
|
436 } |
|
437 |
|
438 private static class ExtendedAddressFactory implements PropertyFactory { |
|
439 private static final long serialVersionUID = 1L; |
|
440 |
|
441 public Property createProperty(final String name, |
|
442 final ParameterList parameters, final String value) |
|
443 throws IOException, URISyntaxException, ParseException { |
|
444 return new ExtendedAddress(parameters, value); |
|
445 } |
|
446 |
|
447 public Property createProperty(final String name) { |
|
448 return new ExtendedAddress(); |
|
449 } |
|
450 } |
|
451 |
|
452 private static class FreeBusyFactory implements PropertyFactory { |
|
453 private static final long serialVersionUID = 1L; |
|
454 |
|
455 public Property createProperty(final String name, |
|
456 final ParameterList parameters, final String value) |
|
457 throws IOException, URISyntaxException, ParseException { |
|
458 return new FreeBusy(parameters, value); |
|
459 } |
|
460 |
|
461 public Property createProperty(final String name) { |
|
462 return new FreeBusy(); |
|
463 } |
|
464 } |
|
465 |
|
466 private static class GeoFactory implements PropertyFactory { |
|
467 private static final long serialVersionUID = 1L; |
|
468 |
|
469 public Property createProperty(final String name, |
|
470 final ParameterList parameters, final String value) |
|
471 throws IOException, URISyntaxException, ParseException { |
|
472 return new Geo(parameters, value); |
|
473 } |
|
474 |
|
475 public Property createProperty(final String name) { |
|
476 return new Geo(); |
|
477 } |
|
478 } |
|
479 |
|
480 private static class LastModifiedFactory implements PropertyFactory { |
|
481 private static final long serialVersionUID = 1L; |
|
482 |
|
483 public Property createProperty(final String name, |
|
484 final ParameterList parameters, final String value) |
|
485 throws IOException, URISyntaxException, ParseException { |
|
486 return new LastModified(parameters, value); |
|
487 } |
|
488 |
|
489 public Property createProperty(final String name) { |
|
490 return new LastModified(); |
|
491 } |
|
492 } |
|
493 |
|
494 private static class LocalityFactory implements PropertyFactory { |
|
495 private static final long serialVersionUID = 1L; |
|
496 |
|
497 public Property createProperty(final String name, |
|
498 final ParameterList parameters, final String value) |
|
499 throws IOException, URISyntaxException, ParseException { |
|
500 return new Locality(parameters, value); |
|
501 } |
|
502 |
|
503 public Property createProperty(final String name) { |
|
504 return new Locality(); |
|
505 } |
|
506 } |
|
507 |
|
508 private static class LocationFactory implements PropertyFactory { |
|
509 private static final long serialVersionUID = 1L; |
|
510 |
|
511 public Property createProperty(final String name, |
|
512 final ParameterList parameters, final String value) |
|
513 throws IOException, URISyntaxException, ParseException { |
|
514 return new Location(parameters, value); |
|
515 } |
|
516 |
|
517 public Property createProperty(final String name) { |
|
518 return new Location(); |
|
519 } |
|
520 } |
|
521 |
|
522 private static class LocationTypeFactory implements PropertyFactory { |
|
523 private static final long serialVersionUID = 1L; |
|
524 |
|
525 public Property createProperty(final String name, |
|
526 final ParameterList parameters, final String value) |
|
527 throws IOException, URISyntaxException, ParseException { |
|
528 return new LocationType(parameters, value); |
|
529 } |
|
530 |
|
531 public Property createProperty(final String name) { |
|
532 return new LocationType(); |
|
533 } |
|
534 } |
|
535 |
|
536 private static class MethodFactory implements PropertyFactory { |
|
537 private static final long serialVersionUID = 1L; |
|
538 |
|
539 public Property createProperty(final String name, |
|
540 final ParameterList parameters, final String value) |
|
541 throws IOException, URISyntaxException, ParseException { |
|
542 return new Method(parameters, value); |
|
543 } |
|
544 |
|
545 public Property createProperty(final String name) { |
|
546 return new Method(); |
|
547 } |
|
548 } |
|
549 |
|
550 private static class NameFactory implements PropertyFactory { |
|
551 private static final long serialVersionUID = 1L; |
|
552 |
|
553 public Property createProperty(final String name, |
|
554 final ParameterList parameters, final String value) |
|
555 throws IOException, URISyntaxException, ParseException { |
|
556 return new Name(parameters, value); |
|
557 } |
|
558 |
|
559 public Property createProperty(final String name) { |
|
560 return new Name(); |
|
561 } |
|
562 } |
|
563 |
|
564 private static class OrganizerFactory implements PropertyFactory { |
|
565 private static final long serialVersionUID = 1L; |
|
566 |
|
567 public Property createProperty(final String name, |
|
568 final ParameterList parameters, final String value) |
|
569 throws IOException, URISyntaxException, ParseException { |
|
570 return new Organizer(parameters, value); |
|
571 } |
|
572 |
|
573 public Property createProperty(final String name) { |
|
574 return new Organizer(); |
|
575 } |
|
576 } |
|
577 |
|
578 private static class PercentCompleteFactory implements PropertyFactory { |
|
579 private static final long serialVersionUID = 1L; |
|
580 |
|
581 public Property createProperty(final String name, |
|
582 final ParameterList parameters, final String value) |
|
583 throws IOException, URISyntaxException, ParseException { |
|
584 return new PercentComplete(parameters, value); |
|
585 } |
|
586 |
|
587 public Property createProperty(final String name) { |
|
588 return new PercentComplete(); |
|
589 } |
|
590 } |
|
591 |
|
592 private static class PostalcodeFactory implements PropertyFactory { |
|
593 private static final long serialVersionUID = 1L; |
|
594 |
|
595 public Property createProperty(final String name, |
|
596 final ParameterList parameters, final String value) |
|
597 throws IOException, URISyntaxException, ParseException { |
|
598 return new Postalcode(parameters, value); |
|
599 } |
|
600 |
|
601 public Property createProperty(final String name) { |
|
602 return new Postalcode(); |
|
603 } |
|
604 } |
|
605 |
|
606 private static class PriorityFactory implements PropertyFactory { |
|
607 private static final long serialVersionUID = 1L; |
|
608 |
|
609 public Property createProperty(final String name, |
|
610 final ParameterList parameters, final String value) |
|
611 throws IOException, URISyntaxException, ParseException { |
|
612 return new Priority(parameters, value); |
|
613 } |
|
614 |
|
615 public Property createProperty(final String name) { |
|
616 return new Priority(); |
|
617 } |
|
618 } |
|
619 |
|
620 private static class ProdIdFactory implements PropertyFactory { |
|
621 private static final long serialVersionUID = 1L; |
|
622 |
|
623 public Property createProperty(final String name, |
|
624 final ParameterList parameters, final String value) |
|
625 throws IOException, URISyntaxException, ParseException { |
|
626 return new ProdId(parameters, value); |
|
627 } |
|
628 |
|
629 public Property createProperty(final String name) { |
|
630 return new ProdId(); |
|
631 } |
|
632 } |
|
633 |
|
634 private static class RDateFactory implements PropertyFactory { |
|
635 private static final long serialVersionUID = 1L; |
|
636 |
|
637 public Property createProperty(final String name, |
|
638 final ParameterList parameters, final String value) |
|
639 throws IOException, URISyntaxException, ParseException { |
|
640 return new RDate(parameters, value); |
|
641 } |
|
642 |
|
643 public Property createProperty(final String name) { |
|
644 return new RDate(); |
|
645 } |
|
646 } |
|
647 |
|
648 private static class RecurrenceIdFactory implements PropertyFactory { |
|
649 private static final long serialVersionUID = 1L; |
|
650 |
|
651 public Property createProperty(final String name, |
|
652 final ParameterList parameters, final String value) |
|
653 throws IOException, URISyntaxException, ParseException { |
|
654 return new RecurrenceId(parameters, value); |
|
655 } |
|
656 |
|
657 public Property createProperty(final String name) { |
|
658 return new RecurrenceId(); |
|
659 } |
|
660 } |
|
661 |
|
662 private static class RegionFactory implements PropertyFactory { |
|
663 private static final long serialVersionUID = 1L; |
|
664 |
|
665 public Property createProperty(final String name, |
|
666 final ParameterList parameters, final String value) |
|
667 throws IOException, URISyntaxException, ParseException { |
|
668 return new Region(parameters, value); |
|
669 } |
|
670 |
|
671 public Property createProperty(final String name) { |
|
672 return new Region(); |
|
673 } |
|
674 } |
|
675 |
|
676 private static class RelatedToFactory implements PropertyFactory { |
|
677 private static final long serialVersionUID = 1L; |
|
678 |
|
679 public Property createProperty(final String name, |
|
680 final ParameterList parameters, final String value) |
|
681 throws IOException, URISyntaxException, ParseException { |
|
682 return new RelatedTo(parameters, value); |
|
683 } |
|
684 |
|
685 public Property createProperty(final String name) { |
|
686 return new RelatedTo(); |
|
687 } |
|
688 } |
|
689 |
|
690 private static class RepeatFactory implements PropertyFactory { |
|
691 private static final long serialVersionUID = 1L; |
|
692 |
|
693 public Property createProperty(final String name, |
|
694 final ParameterList parameters, final String value) |
|
695 throws IOException, URISyntaxException, ParseException { |
|
696 return new Repeat(parameters, value); |
|
697 } |
|
698 |
|
699 public Property createProperty(final String name) { |
|
700 return new Repeat(); |
|
701 } |
|
702 } |
|
703 |
|
704 private static class RequestStatusFactory implements PropertyFactory { |
|
705 private static final long serialVersionUID = 1L; |
|
706 |
|
707 public Property createProperty(final String name, |
|
708 final ParameterList parameters, final String value) |
|
709 throws IOException, URISyntaxException, ParseException { |
|
710 return new RequestStatus(parameters, value); |
|
711 } |
|
712 |
|
713 public Property createProperty(final String name) { |
|
714 return new RequestStatus(); |
|
715 } |
|
716 } |
|
717 |
|
718 private static class ResourcesFactory implements PropertyFactory { |
|
719 private static final long serialVersionUID = 1L; |
|
720 |
|
721 public Property createProperty(final String name, |
|
722 final ParameterList parameters, final String value) |
|
723 throws IOException, URISyntaxException, ParseException { |
|
724 return new Resources(parameters, value); |
|
725 } |
|
726 |
|
727 public Property createProperty(final String name) { |
|
728 return new Resources(); |
|
729 } |
|
730 } |
|
731 |
|
732 private static class RRuleFactory implements PropertyFactory { |
|
733 private static final long serialVersionUID = 1L; |
|
734 |
|
735 public Property createProperty(final String name, |
|
736 final ParameterList parameters, final String value) |
|
737 throws IOException, URISyntaxException, ParseException { |
|
738 return new RRule(parameters, value); |
|
739 } |
|
740 |
|
741 public Property createProperty(final String name) { |
|
742 return new RRule(); |
|
743 } |
|
744 } |
|
745 |
|
746 private static class SequenceFactory implements PropertyFactory { |
|
747 private static final long serialVersionUID = 1L; |
|
748 |
|
749 public Property createProperty(final String name, |
|
750 final ParameterList parameters, final String value) |
|
751 throws IOException, URISyntaxException, ParseException { |
|
752 return new Sequence(parameters, value); |
|
753 } |
|
754 |
|
755 public Property createProperty(final String name) { |
|
756 return new Sequence(); |
|
757 } |
|
758 } |
|
759 |
|
760 private static class StatusFactory implements PropertyFactory { |
|
761 private static final long serialVersionUID = 1L; |
|
762 |
|
763 public Property createProperty(final String name, |
|
764 final ParameterList parameters, final String value) |
|
765 throws IOException, URISyntaxException, ParseException { |
|
766 return new Status(parameters, value); |
|
767 } |
|
768 |
|
769 public Property createProperty(final String name) { |
|
770 return new Status(); |
|
771 } |
|
772 } |
|
773 |
|
774 private static class StreetAddressFactory implements PropertyFactory { |
|
775 private static final long serialVersionUID = 1L; |
|
776 |
|
777 public Property createProperty(final String name, |
|
778 final ParameterList parameters, final String value) |
|
779 throws IOException, URISyntaxException, ParseException { |
|
780 return new StreetAddress(parameters, value); |
|
781 } |
|
782 |
|
783 public Property createProperty(final String name) { |
|
784 return new StreetAddress(); |
|
785 } |
|
786 } |
|
787 |
|
788 private static class SummaryFactory implements PropertyFactory { |
|
789 private static final long serialVersionUID = 1L; |
|
790 |
|
791 public Property createProperty(final String name, |
|
792 final ParameterList parameters, final String value) |
|
793 throws IOException, URISyntaxException, ParseException { |
|
794 return new Summary(parameters, value); |
|
795 } |
|
796 |
|
797 public Property createProperty(final String name) { |
|
798 return new Summary(); |
|
799 } |
|
800 } |
|
801 |
|
802 private static class TelFactory implements PropertyFactory { |
|
803 private static final long serialVersionUID = 1L; |
|
804 |
|
805 public Property createProperty(final String name, |
|
806 final ParameterList parameters, final String value) |
|
807 throws IOException, URISyntaxException, ParseException { |
|
808 return new Tel(parameters, value); |
|
809 } |
|
810 |
|
811 public Property createProperty(final String name) { |
|
812 return new Tel(); |
|
813 } |
|
814 } |
|
815 |
|
816 private static class TranspFactory implements PropertyFactory { |
|
817 private static final long serialVersionUID = 1L; |
|
818 |
|
819 public Property createProperty(final String name, |
|
820 final ParameterList parameters, final String value) |
|
821 throws IOException, URISyntaxException, ParseException { |
|
822 return new Transp(parameters, value); |
|
823 } |
|
824 |
|
825 public Property createProperty(final String name) { |
|
826 return new Transp(); |
|
827 } |
|
828 } |
|
829 |
|
830 private static class TriggerFactory implements PropertyFactory { |
|
831 private static final long serialVersionUID = 1L; |
|
832 |
|
833 public Property createProperty(final String name, |
|
834 final ParameterList parameters, final String value) |
|
835 throws IOException, URISyntaxException, ParseException { |
|
836 return new Trigger(parameters, value); |
|
837 } |
|
838 |
|
839 public Property createProperty(final String name) { |
|
840 return new Trigger(); |
|
841 } |
|
842 } |
|
843 |
|
844 private static class TzIdFactory implements PropertyFactory { |
|
845 private static final long serialVersionUID = 1L; |
|
846 |
|
847 public Property createProperty(final String name, |
|
848 final ParameterList parameters, final String value) |
|
849 throws IOException, URISyntaxException, ParseException { |
|
850 return new TzId(parameters, value); |
|
851 } |
|
852 |
|
853 public Property createProperty(final String name) { |
|
854 return new TzId(); |
|
855 } |
|
856 } |
|
857 |
|
858 private static class TzNameFactory implements PropertyFactory { |
|
859 private static final long serialVersionUID = 1L; |
|
860 |
|
861 public Property createProperty(final String name, |
|
862 final ParameterList parameters, final String value) |
|
863 throws IOException, URISyntaxException, ParseException { |
|
864 return new TzName(parameters, value); |
|
865 } |
|
866 |
|
867 public Property createProperty(final String name) { |
|
868 return new TzName(); |
|
869 } |
|
870 } |
|
871 |
|
872 private static class TzOffsetFromFactory implements PropertyFactory { |
|
873 private static final long serialVersionUID = 1L; |
|
874 |
|
875 public Property createProperty(final String name, |
|
876 final ParameterList parameters, final String value) |
|
877 throws IOException, URISyntaxException, ParseException { |
|
878 return new TzOffsetFrom(parameters, value); |
|
879 } |
|
880 |
|
881 public Property createProperty(final String name) { |
|
882 return new TzOffsetFrom(); |
|
883 } |
|
884 } |
|
885 |
|
886 private static class TzOffsetToFactory implements PropertyFactory { |
|
887 private static final long serialVersionUID = 1L; |
|
888 |
|
889 public Property createProperty(final String name, |
|
890 final ParameterList parameters, final String value) |
|
891 throws IOException, URISyntaxException, ParseException { |
|
892 return new TzOffsetTo(parameters, value); |
|
893 } |
|
894 |
|
895 public Property createProperty(final String name) { |
|
896 return new TzOffsetTo(); |
|
897 } |
|
898 } |
|
899 |
|
900 private static class TzUrlFactory implements PropertyFactory { |
|
901 private static final long serialVersionUID = 1L; |
|
902 |
|
903 public Property createProperty(final String name, |
|
904 final ParameterList parameters, final String value) |
|
905 throws IOException, URISyntaxException, ParseException { |
|
906 return new TzUrl(parameters, value); |
|
907 } |
|
908 |
|
909 public Property createProperty(final String name) { |
|
910 return new TzUrl(); |
|
911 } |
|
912 } |
|
913 |
|
914 private static class UidFactory implements PropertyFactory { |
|
915 private static final long serialVersionUID = 1L; |
|
916 |
|
917 public Property createProperty(final String name, |
|
918 final ParameterList parameters, final String value) |
|
919 throws IOException, URISyntaxException, ParseException { |
|
920 return new Uid(parameters, value); |
|
921 } |
|
922 |
|
923 public Property createProperty(final String name) { |
|
924 return new Uid(); |
|
925 } |
|
926 } |
|
927 |
|
928 private static class UrlFactory implements PropertyFactory { |
|
929 private static final long serialVersionUID = 1L; |
|
930 |
|
931 public Property createProperty(final String name, |
|
932 final ParameterList parameters, final String value) |
|
933 throws IOException, URISyntaxException, ParseException { |
|
934 return new Url(parameters, value); |
|
935 } |
|
936 |
|
937 public Property createProperty(final String name) { |
|
938 return new Url(); |
|
939 } |
|
940 } |
|
941 |
|
942 private static class VersionFactory implements PropertyFactory { |
|
943 private static final long serialVersionUID = 1L; |
|
944 |
|
945 public Property createProperty(final String name, |
|
946 final ParameterList parameters, final String value) |
|
947 throws IOException, URISyntaxException, ParseException { |
|
948 return new Version(parameters, value); |
|
949 } |
|
950 |
|
951 public Property createProperty(final String name) { |
|
952 return new Version(); |
|
953 } |
|
954 } |
|
955 |
|
956 /** |
|
957 * @return Returns the instance. |
|
958 */ |
|
959 public static PropertyFactoryImpl getInstance() { |
|
960 return instance; |
|
961 } |
|
962 |
|
963 /** |
|
964 * {@inheritDoc} |
|
965 */ |
|
966 public Property createProperty(final String name) { |
|
967 final PropertyFactory factory = (PropertyFactory) getFactory(name); |
|
968 if (factory != null) { |
|
969 return factory.createProperty(name); |
|
970 } |
|
971 else if (isExperimentalName(name)) { |
|
972 return new XProperty(name); |
|
973 } |
|
974 else if (allowIllegalNames()) { |
|
975 return new XProperty(name); |
|
976 } |
|
977 else { |
|
978 throw new IllegalArgumentException("Illegal property [" + name |
|
979 + "]"); |
|
980 } |
|
981 } |
|
982 |
|
983 /** |
|
984 * {@inheritDoc} |
|
985 */ |
|
986 public Property createProperty(final String name, |
|
987 final ParameterList parameters, final String value) |
|
988 throws IOException, URISyntaxException, ParseException { |
|
989 |
|
990 final PropertyFactory factory = (PropertyFactory) getFactory(name); |
|
991 if (factory != null) { |
|
992 return factory.createProperty(name, parameters, value); |
|
993 } |
|
994 else if (isExperimentalName(name)) { |
|
995 return new XProperty(name, parameters, value); |
|
996 } |
|
997 else if (allowIllegalNames()) { |
|
998 return new XProperty(name, parameters, value); |
|
999 } |
|
1000 else { |
|
1001 throw new IllegalArgumentException("Illegal property [" + name |
|
1002 + "]"); |
|
1003 } |
|
1004 } |
|
1005 |
|
1006 /** |
|
1007 * @param name |
|
1008 * @return |
|
1009 */ |
|
1010 private boolean isExperimentalName(final String name) { |
|
1011 return name.startsWith(Property.EXPERIMENTAL_PREFIX) |
|
1012 && name.length() > Property.EXPERIMENTAL_PREFIX.length(); |
|
1013 } |
|
1014 } |
|