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

Tue, 10 Feb 2015 19:58:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 19:58:00 +0100
changeset 4
45d57ecba757
parent 0
fb9019fb1bf7
permissions
-rw-r--r--

Upgrade the upgraded ical4j component to use org.apache.commons.lang3.

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

mercurial