src/net/fortuna/ical4j/model/PropertyFactoryImpl.java

Tue, 10 Feb 2015 18:12:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 18:12:00 +0100
changeset 0
fb9019fb1bf7
child 3
73bdfa70b04e
permissions
-rw-r--r--

Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.

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

mercurial