Tue, 10 Feb 2015 19:58:00 +0100
Upgrade the upgraded ical4j component to use org.apache.commons.lang3.
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;
34 import java.io.IOException;
35 import java.net.URISyntaxException;
36 import java.text.ParseException;
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;
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 {
106 private static final long serialVersionUID = -7174232004486979641L;
108 private static PropertyFactoryImpl instance = new PropertyFactoryImpl();
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 }
172 private static class ActionFactory implements PropertyFactory {
173 private static final long serialVersionUID = 1L;
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 }
181 public Property createProperty(final String name) {
182 return new Action();
183 }
184 }
186 private static class AttachFactory implements PropertyFactory {
187 private static final long serialVersionUID = 1L;
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 }
195 public Property createProperty(final String name) {
196 return new Attach();
197 }
198 }
200 private static class AttendeeFactory implements PropertyFactory {
201 private static final long serialVersionUID = 1L;
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 }
209 public Property createProperty(final String name) {
210 return new Attendee();
211 }
212 }
214 private static class CalScaleFactory implements PropertyFactory {
215 private static final long serialVersionUID = 1L;
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 }
223 public Property createProperty(final String name) {
224 return new CalScale();
225 }
226 }
228 private static class CategoriesFactory implements PropertyFactory {
229 private static final long serialVersionUID = 1L;
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 }
237 public Property createProperty(final String name) {
238 return new Categories();
239 }
240 }
242 private static class ClazzFactory implements PropertyFactory {
243 private static final long serialVersionUID = 1L;
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 }
251 public Property createProperty(final String name) {
252 return new Clazz();
253 }
254 }
256 private static class CommentFactory implements PropertyFactory {
257 private static final long serialVersionUID = 1L;
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 }
265 public Property createProperty(final String name) {
266 return new Comment();
267 }
268 }
270 private static class CompletedFactory implements PropertyFactory {
271 private static final long serialVersionUID = 1L;
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 }
279 public Property createProperty(final String name) {
280 return new Completed();
281 }
282 }
284 private static class ContactFactory implements PropertyFactory {
285 private static final long serialVersionUID = 1L;
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 }
293 public Property createProperty(final String name) {
294 return new Contact();
295 }
296 }
298 private static class CountryFactory implements PropertyFactory {
299 private static final long serialVersionUID = 1L;
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 }
307 public Property createProperty(final String name) {
308 return new Country();
309 }
310 }
312 private static class CreatedFactory implements PropertyFactory {
313 private static final long serialVersionUID = 1L;
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 }
321 public Property createProperty(final String name) {
322 return new Created();
323 }
324 }
326 private static class DescriptionFactory implements PropertyFactory {
327 private static final long serialVersionUID = 1L;
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 }
335 public Property createProperty(final String name) {
336 return new Description();
337 }
338 }
340 private static class DtEndFactory implements PropertyFactory {
341 private static final long serialVersionUID = 1L;
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 }
349 public Property createProperty(final String name) {
350 return new DtEnd();
351 }
352 }
354 private static class DtStampFactory implements PropertyFactory {
355 private static final long serialVersionUID = 1L;
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 }
363 public Property createProperty(final String name) {
364 return new DtStamp();
365 }
366 }
368 private static class DtStartFactory implements PropertyFactory {
369 private static final long serialVersionUID = 1L;
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 }
377 public Property createProperty(final String name) {
378 return new DtStart();
379 }
380 }
382 private static class DueFactory implements PropertyFactory {
383 private static final long serialVersionUID = 1L;
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 }
391 public Property createProperty(final String name) {
392 return new Due();
393 }
394 }
396 private static class DurationFactory implements PropertyFactory {
397 private static final long serialVersionUID = 1L;
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 }
405 public Property createProperty(final String name) {
406 return new Duration();
407 }
408 }
410 private static class ExDateFactory implements PropertyFactory {
411 private static final long serialVersionUID = 1L;
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 }
419 public Property createProperty(final String name) {
420 return new ExDate();
421 }
422 }
424 private static class ExRuleFactory implements PropertyFactory {
425 private static final long serialVersionUID = 1L;
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 }
433 public Property createProperty(final String name) {
434 return new ExRule();
435 }
436 }
438 private static class ExtendedAddressFactory implements PropertyFactory {
439 private static final long serialVersionUID = 1L;
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 }
447 public Property createProperty(final String name) {
448 return new ExtendedAddress();
449 }
450 }
452 private static class FreeBusyFactory implements PropertyFactory {
453 private static final long serialVersionUID = 1L;
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 }
461 public Property createProperty(final String name) {
462 return new FreeBusy();
463 }
464 }
466 private static class GeoFactory implements PropertyFactory {
467 private static final long serialVersionUID = 1L;
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 }
475 public Property createProperty(final String name) {
476 return new Geo();
477 }
478 }
480 private static class LastModifiedFactory implements PropertyFactory {
481 private static final long serialVersionUID = 1L;
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 }
489 public Property createProperty(final String name) {
490 return new LastModified();
491 }
492 }
494 private static class LocalityFactory implements PropertyFactory {
495 private static final long serialVersionUID = 1L;
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 }
503 public Property createProperty(final String name) {
504 return new Locality();
505 }
506 }
508 private static class LocationFactory implements PropertyFactory {
509 private static final long serialVersionUID = 1L;
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 }
517 public Property createProperty(final String name) {
518 return new Location();
519 }
520 }
522 private static class LocationTypeFactory implements PropertyFactory {
523 private static final long serialVersionUID = 1L;
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 }
531 public Property createProperty(final String name) {
532 return new LocationType();
533 }
534 }
536 private static class MethodFactory implements PropertyFactory {
537 private static final long serialVersionUID = 1L;
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 }
545 public Property createProperty(final String name) {
546 return new Method();
547 }
548 }
550 private static class NameFactory implements PropertyFactory {
551 private static final long serialVersionUID = 1L;
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 }
559 public Property createProperty(final String name) {
560 return new Name();
561 }
562 }
564 private static class OrganizerFactory implements PropertyFactory {
565 private static final long serialVersionUID = 1L;
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 }
573 public Property createProperty(final String name) {
574 return new Organizer();
575 }
576 }
578 private static class PercentCompleteFactory implements PropertyFactory {
579 private static final long serialVersionUID = 1L;
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 }
587 public Property createProperty(final String name) {
588 return new PercentComplete();
589 }
590 }
592 private static class PostalcodeFactory implements PropertyFactory {
593 private static final long serialVersionUID = 1L;
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 }
601 public Property createProperty(final String name) {
602 return new Postalcode();
603 }
604 }
606 private static class PriorityFactory implements PropertyFactory {
607 private static final long serialVersionUID = 1L;
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 }
615 public Property createProperty(final String name) {
616 return new Priority();
617 }
618 }
620 private static class ProdIdFactory implements PropertyFactory {
621 private static final long serialVersionUID = 1L;
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 }
629 public Property createProperty(final String name) {
630 return new ProdId();
631 }
632 }
634 private static class RDateFactory implements PropertyFactory {
635 private static final long serialVersionUID = 1L;
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 }
643 public Property createProperty(final String name) {
644 return new RDate();
645 }
646 }
648 private static class RecurrenceIdFactory implements PropertyFactory {
649 private static final long serialVersionUID = 1L;
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 }
657 public Property createProperty(final String name) {
658 return new RecurrenceId();
659 }
660 }
662 private static class RegionFactory implements PropertyFactory {
663 private static final long serialVersionUID = 1L;
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 }
671 public Property createProperty(final String name) {
672 return new Region();
673 }
674 }
676 private static class RelatedToFactory implements PropertyFactory {
677 private static final long serialVersionUID = 1L;
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 }
685 public Property createProperty(final String name) {
686 return new RelatedTo();
687 }
688 }
690 private static class RepeatFactory implements PropertyFactory {
691 private static final long serialVersionUID = 1L;
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 }
699 public Property createProperty(final String name) {
700 return new Repeat();
701 }
702 }
704 private static class RequestStatusFactory implements PropertyFactory {
705 private static final long serialVersionUID = 1L;
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 }
713 public Property createProperty(final String name) {
714 return new RequestStatus();
715 }
716 }
718 private static class ResourcesFactory implements PropertyFactory {
719 private static final long serialVersionUID = 1L;
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 }
727 public Property createProperty(final String name) {
728 return new Resources();
729 }
730 }
732 private static class RRuleFactory implements PropertyFactory {
733 private static final long serialVersionUID = 1L;
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 }
741 public Property createProperty(final String name) {
742 return new RRule();
743 }
744 }
746 private static class SequenceFactory implements PropertyFactory {
747 private static final long serialVersionUID = 1L;
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 }
755 public Property createProperty(final String name) {
756 return new Sequence();
757 }
758 }
760 private static class StatusFactory implements PropertyFactory {
761 private static final long serialVersionUID = 1L;
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 }
769 public Property createProperty(final String name) {
770 return new Status();
771 }
772 }
774 private static class StreetAddressFactory implements PropertyFactory {
775 private static final long serialVersionUID = 1L;
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 }
783 public Property createProperty(final String name) {
784 return new StreetAddress();
785 }
786 }
788 private static class SummaryFactory implements PropertyFactory {
789 private static final long serialVersionUID = 1L;
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 }
797 public Property createProperty(final String name) {
798 return new Summary();
799 }
800 }
802 private static class TelFactory implements PropertyFactory {
803 private static final long serialVersionUID = 1L;
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 }
811 public Property createProperty(final String name) {
812 return new Tel();
813 }
814 }
816 private static class TranspFactory implements PropertyFactory {
817 private static final long serialVersionUID = 1L;
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 }
825 public Property createProperty(final String name) {
826 return new Transp();
827 }
828 }
830 private static class TriggerFactory implements PropertyFactory {
831 private static final long serialVersionUID = 1L;
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 }
839 public Property createProperty(final String name) {
840 return new Trigger();
841 }
842 }
844 private static class TzIdFactory implements PropertyFactory {
845 private static final long serialVersionUID = 1L;
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 }
853 public Property createProperty(final String name) {
854 return new TzId();
855 }
856 }
858 private static class TzNameFactory implements PropertyFactory {
859 private static final long serialVersionUID = 1L;
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 }
867 public Property createProperty(final String name) {
868 return new TzName();
869 }
870 }
872 private static class TzOffsetFromFactory implements PropertyFactory {
873 private static final long serialVersionUID = 1L;
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 }
881 public Property createProperty(final String name) {
882 return new TzOffsetFrom();
883 }
884 }
886 private static class TzOffsetToFactory implements PropertyFactory {
887 private static final long serialVersionUID = 1L;
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 }
895 public Property createProperty(final String name) {
896 return new TzOffsetTo();
897 }
898 }
900 private static class TzUrlFactory implements PropertyFactory {
901 private static final long serialVersionUID = 1L;
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 }
909 public Property createProperty(final String name) {
910 return new TzUrl();
911 }
912 }
914 private static class UidFactory implements PropertyFactory {
915 private static final long serialVersionUID = 1L;
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 }
923 public Property createProperty(final String name) {
924 return new Uid();
925 }
926 }
928 private static class UrlFactory implements PropertyFactory {
929 private static final long serialVersionUID = 1L;
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 }
937 public Property createProperty(final String name) {
938 return new Url();
939 }
940 }
942 private static class VersionFactory implements PropertyFactory {
943 private static final long serialVersionUID = 1L;
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 }
951 public Property createProperty(final String name) {
952 return new Version();
953 }
954 }
956 /**
957 * @return Returns the instance.
958 */
959 public static PropertyFactoryImpl getInstance() {
960 return instance;
961 }
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 }
983 /**
984 * {@inheritDoc}
985 */
986 public Property createProperty(final String name,
987 final ParameterList parameters, final String value)
988 throws IOException, URISyntaxException, ParseException {
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 }
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 }