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

changeset 0
fb9019fb1bf7
child 3
73bdfa70b04e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/net/fortuna/ical4j/model/PropertyFactoryImpl.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,1017 @@
     1.4 +/**
     1.5 + * Copyright (c) 2012, Ben Fortuna
     1.6 + * All rights reserved.
     1.7 + *
     1.8 + * Redistribution and use in source and binary forms, with or without
     1.9 + * modification, are permitted provided that the following conditions
    1.10 + * are met:
    1.11 + *
    1.12 + *  o Redistributions of source code must retain the above copyright
    1.13 + * notice, this list of conditions and the following disclaimer.
    1.14 + *
    1.15 + *  o Redistributions in binary form must reproduce the above copyright
    1.16 + * notice, this list of conditions and the following disclaimer in the
    1.17 + * documentation and/or other materials provided with the distribution.
    1.18 + *
    1.19 + *  o Neither the name of Ben Fortuna nor the names of any other contributors
    1.20 + * may be used to endorse or promote products derived from this software
    1.21 + * without specific prior written permission.
    1.22 + *
    1.23 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.24 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.25 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.26 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    1.27 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.28 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.29 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    1.30 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    1.31 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    1.32 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    1.33 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.34 + */
    1.35 +package net.fortuna.ical4j.model;
    1.36 +
    1.37 +import java.io.IOException;
    1.38 +import java.net.URISyntaxException;
    1.39 +import java.text.ParseException;
    1.40 +
    1.41 +import net.fortuna.ical4j.model.property.Action;
    1.42 +import net.fortuna.ical4j.model.property.Attach;
    1.43 +import net.fortuna.ical4j.model.property.Attendee;
    1.44 +import net.fortuna.ical4j.model.property.CalScale;
    1.45 +import net.fortuna.ical4j.model.property.Categories;
    1.46 +import net.fortuna.ical4j.model.property.Clazz;
    1.47 +import net.fortuna.ical4j.model.property.Comment;
    1.48 +import net.fortuna.ical4j.model.property.Completed;
    1.49 +import net.fortuna.ical4j.model.property.Contact;
    1.50 +import net.fortuna.ical4j.model.property.Country;
    1.51 +import net.fortuna.ical4j.model.property.Created;
    1.52 +import net.fortuna.ical4j.model.property.Description;
    1.53 +import net.fortuna.ical4j.model.property.DtEnd;
    1.54 +import net.fortuna.ical4j.model.property.DtStamp;
    1.55 +import net.fortuna.ical4j.model.property.DtStart;
    1.56 +import net.fortuna.ical4j.model.property.Due;
    1.57 +import net.fortuna.ical4j.model.property.Duration;
    1.58 +import net.fortuna.ical4j.model.property.ExDate;
    1.59 +import net.fortuna.ical4j.model.property.ExRule;
    1.60 +import net.fortuna.ical4j.model.property.ExtendedAddress;
    1.61 +import net.fortuna.ical4j.model.property.FreeBusy;
    1.62 +import net.fortuna.ical4j.model.property.Geo;
    1.63 +import net.fortuna.ical4j.model.property.LastModified;
    1.64 +import net.fortuna.ical4j.model.property.Locality;
    1.65 +import net.fortuna.ical4j.model.property.Location;
    1.66 +import net.fortuna.ical4j.model.property.LocationType;
    1.67 +import net.fortuna.ical4j.model.property.Method;
    1.68 +import net.fortuna.ical4j.model.property.Name;
    1.69 +import net.fortuna.ical4j.model.property.Organizer;
    1.70 +import net.fortuna.ical4j.model.property.PercentComplete;
    1.71 +import net.fortuna.ical4j.model.property.Postalcode;
    1.72 +import net.fortuna.ical4j.model.property.Priority;
    1.73 +import net.fortuna.ical4j.model.property.ProdId;
    1.74 +import net.fortuna.ical4j.model.property.RDate;
    1.75 +import net.fortuna.ical4j.model.property.RRule;
    1.76 +import net.fortuna.ical4j.model.property.RecurrenceId;
    1.77 +import net.fortuna.ical4j.model.property.Region;
    1.78 +import net.fortuna.ical4j.model.property.RelatedTo;
    1.79 +import net.fortuna.ical4j.model.property.Repeat;
    1.80 +import net.fortuna.ical4j.model.property.RequestStatus;
    1.81 +import net.fortuna.ical4j.model.property.Resources;
    1.82 +import net.fortuna.ical4j.model.property.Sequence;
    1.83 +import net.fortuna.ical4j.model.property.Status;
    1.84 +import net.fortuna.ical4j.model.property.StreetAddress;
    1.85 +import net.fortuna.ical4j.model.property.Summary;
    1.86 +import net.fortuna.ical4j.model.property.Tel;
    1.87 +import net.fortuna.ical4j.model.property.Transp;
    1.88 +import net.fortuna.ical4j.model.property.Trigger;
    1.89 +import net.fortuna.ical4j.model.property.TzId;
    1.90 +import net.fortuna.ical4j.model.property.TzName;
    1.91 +import net.fortuna.ical4j.model.property.TzOffsetFrom;
    1.92 +import net.fortuna.ical4j.model.property.TzOffsetTo;
    1.93 +import net.fortuna.ical4j.model.property.TzUrl;
    1.94 +import net.fortuna.ical4j.model.property.Uid;
    1.95 +import net.fortuna.ical4j.model.property.Url;
    1.96 +import net.fortuna.ical4j.model.property.Version;
    1.97 +import net.fortuna.ical4j.model.property.XProperty;
    1.98 +
    1.99 +/**
   1.100 + * A factory for creating iCalendar properties. Note that if relaxed parsing is enabled (via specifying the system
   1.101 + * property: icalj.parsing.relaxed=true) illegal property names are allowed.
   1.102 + * 
   1.103 + * @author Ben Fortuna
   1.104 + * 
   1.105 + * $Id$ [05-Apr-2004]
   1.106 + */
   1.107 +public class PropertyFactoryImpl extends AbstractContentFactory implements PropertyFactory {
   1.108 +
   1.109 +    private static final long serialVersionUID = -7174232004486979641L;
   1.110 +    
   1.111 +    private static PropertyFactoryImpl instance = new PropertyFactoryImpl();
   1.112 +
   1.113 +    /**
   1.114 +     * Constructor made private to prevent instantiation.
   1.115 +     */
   1.116 +    protected PropertyFactoryImpl() {
   1.117 +        registerDefaultFactory(Property.ACTION, new ActionFactory());
   1.118 +        registerDefaultFactory(Property.ATTACH, new AttachFactory());
   1.119 +        registerDefaultFactory(Property.ATTENDEE, new AttendeeFactory());
   1.120 +        registerDefaultFactory(Property.CALSCALE, new CalScaleFactory());
   1.121 +        registerDefaultFactory(Property.CATEGORIES, new CategoriesFactory());
   1.122 +        registerDefaultFactory(Property.CLASS, new ClazzFactory());
   1.123 +        registerDefaultFactory(Property.COMMENT, new CommentFactory());
   1.124 +        registerDefaultFactory(Property.COMPLETED, new CompletedFactory());
   1.125 +        registerDefaultFactory(Property.CONTACT, new ContactFactory());
   1.126 +        registerDefaultFactory(Property.COUNTRY, new CountryFactory());
   1.127 +        registerDefaultFactory(Property.CREATED, new CreatedFactory());
   1.128 +        registerDefaultFactory(Property.DESCRIPTION, new DescriptionFactory());
   1.129 +        registerDefaultFactory(Property.DTEND, new DtEndFactory());
   1.130 +        registerDefaultFactory(Property.DTSTAMP, new DtStampFactory());
   1.131 +        registerDefaultFactory(Property.DTSTART, new DtStartFactory());
   1.132 +        registerDefaultFactory(Property.DUE, new DueFactory());
   1.133 +        registerDefaultFactory(Property.DURATION, new DurationFactory());
   1.134 +        registerDefaultFactory(Property.EXDATE, new ExDateFactory());
   1.135 +        registerDefaultFactory(Property.EXRULE, new ExRuleFactory());
   1.136 +        registerDefaultFactory(Property.EXTENDED_ADDRESS, new ExtendedAddressFactory());
   1.137 +        registerDefaultFactory(Property.FREEBUSY, new FreeBusyFactory());
   1.138 +        registerDefaultFactory(Property.GEO, new GeoFactory());
   1.139 +        registerDefaultFactory(Property.LAST_MODIFIED, new LastModifiedFactory());
   1.140 +        registerDefaultFactory(Property.LOCALITY, new LocalityFactory());
   1.141 +        registerDefaultFactory(Property.LOCATION, new LocationFactory());
   1.142 +        registerDefaultFactory(Property.LOCATION_TYPE, new LocationTypeFactory());
   1.143 +        registerDefaultFactory(Property.METHOD, new MethodFactory());
   1.144 +        registerDefaultFactory(Property.NAME, new NameFactory());
   1.145 +        registerDefaultFactory(Property.ORGANIZER, new OrganizerFactory());
   1.146 +        registerDefaultFactory(Property.PERCENT_COMPLETE, new PercentCompleteFactory());
   1.147 +        registerDefaultFactory(Property.POSTALCODE, new PostalcodeFactory());
   1.148 +        registerDefaultFactory(Property.PRIORITY, new PriorityFactory());
   1.149 +        registerDefaultFactory(Property.PRODID, new ProdIdFactory());
   1.150 +        registerDefaultFactory(Property.RDATE, new RDateFactory());
   1.151 +        registerDefaultFactory(Property.RECURRENCE_ID, new RecurrenceIdFactory());
   1.152 +        registerDefaultFactory(Property.REGION, new RegionFactory());
   1.153 +        registerDefaultFactory(Property.RELATED_TO, new RelatedToFactory());
   1.154 +        registerDefaultFactory(Property.REPEAT, new RepeatFactory());
   1.155 +        registerDefaultFactory(Property.REQUEST_STATUS, new RequestStatusFactory());
   1.156 +        registerDefaultFactory(Property.RESOURCES, new ResourcesFactory());
   1.157 +        registerDefaultFactory(Property.RRULE, new RRuleFactory());
   1.158 +        registerDefaultFactory(Property.SEQUENCE, new SequenceFactory());
   1.159 +        registerDefaultFactory(Property.STATUS, new StatusFactory());
   1.160 +        registerDefaultFactory(Property.STREET_ADDRESS, new StreetAddressFactory());
   1.161 +        registerDefaultFactory(Property.SUMMARY, new SummaryFactory());
   1.162 +        registerDefaultFactory(Property.TEL, new TelFactory());
   1.163 +        registerDefaultFactory(Property.TRANSP, new TranspFactory());
   1.164 +        registerDefaultFactory(Property.TRIGGER, new TriggerFactory());
   1.165 +        registerDefaultFactory(Property.TZID, new TzIdFactory());
   1.166 +        registerDefaultFactory(Property.TZNAME, new TzNameFactory());
   1.167 +        registerDefaultFactory(Property.TZOFFSETFROM, new TzOffsetFromFactory());
   1.168 +        registerDefaultFactory(Property.TZOFFSETTO, new TzOffsetToFactory());
   1.169 +        registerDefaultFactory(Property.TZURL, new TzUrlFactory());
   1.170 +        registerDefaultFactory(Property.UID, new UidFactory());
   1.171 +        registerDefaultFactory(Property.URL, new UrlFactory());
   1.172 +        registerDefaultFactory(Property.VERSION, new VersionFactory());
   1.173 +    }
   1.174 +
   1.175 +    private static class ActionFactory implements PropertyFactory {
   1.176 +        private static final long serialVersionUID = 1L;
   1.177 +
   1.178 +        public Property createProperty(final String name,
   1.179 +                final ParameterList parameters, final String value)
   1.180 +                throws IOException, URISyntaxException, ParseException {
   1.181 +            return new Action(parameters, value);
   1.182 +        }
   1.183 +
   1.184 +        public Property createProperty(final String name) {
   1.185 +            return new Action();
   1.186 +        }
   1.187 +    }
   1.188 +
   1.189 +    private static class AttachFactory implements PropertyFactory {
   1.190 +        private static final long serialVersionUID = 1L;
   1.191 +
   1.192 +        public Property createProperty(final String name,
   1.193 +                final ParameterList parameters, final String value)
   1.194 +                throws IOException, URISyntaxException, ParseException {
   1.195 +            return new Attach(parameters, value);
   1.196 +        }
   1.197 +
   1.198 +        public Property createProperty(final String name) {
   1.199 +            return new Attach();
   1.200 +        }
   1.201 +    }
   1.202 +
   1.203 +    private static class AttendeeFactory implements PropertyFactory {
   1.204 +        private static final long serialVersionUID = 1L;
   1.205 +
   1.206 +        public Property createProperty(final String name,
   1.207 +                final ParameterList parameters, final String value)
   1.208 +                throws IOException, URISyntaxException, ParseException {
   1.209 +            return new Attendee(parameters, value);
   1.210 +        }
   1.211 +
   1.212 +        public Property createProperty(final String name) {
   1.213 +            return new Attendee();
   1.214 +        }
   1.215 +    }
   1.216 +
   1.217 +    private static class CalScaleFactory implements PropertyFactory {
   1.218 +        private static final long serialVersionUID = 1L;
   1.219 +
   1.220 +        public Property createProperty(final String name,
   1.221 +                final ParameterList parameters, final String value)
   1.222 +                throws IOException, URISyntaxException, ParseException {
   1.223 +            return new CalScale(parameters, value);
   1.224 +        }
   1.225 +
   1.226 +        public Property createProperty(final String name) {
   1.227 +            return new CalScale();
   1.228 +        }
   1.229 +    }
   1.230 +
   1.231 +    private static class CategoriesFactory implements PropertyFactory {
   1.232 +        private static final long serialVersionUID = 1L;
   1.233 +
   1.234 +        public Property createProperty(final String name,
   1.235 +                final ParameterList parameters, final String value)
   1.236 +                throws IOException, URISyntaxException, ParseException {
   1.237 +            return new Categories(parameters, value);
   1.238 +        }
   1.239 +
   1.240 +        public Property createProperty(final String name) {
   1.241 +            return new Categories();
   1.242 +        }
   1.243 +    }
   1.244 +
   1.245 +    private static class ClazzFactory implements PropertyFactory {
   1.246 +        private static final long serialVersionUID = 1L;
   1.247 +
   1.248 +        public Property createProperty(final String name,
   1.249 +                final ParameterList parameters, final String value)
   1.250 +                throws IOException, URISyntaxException, ParseException {
   1.251 +            return new Clazz(parameters, value);
   1.252 +        }
   1.253 +
   1.254 +        public Property createProperty(final String name) {
   1.255 +            return new Clazz();
   1.256 +        }
   1.257 +    }
   1.258 +
   1.259 +    private static class CommentFactory implements PropertyFactory {
   1.260 +        private static final long serialVersionUID = 1L;
   1.261 +
   1.262 +        public Property createProperty(final String name,
   1.263 +                final ParameterList parameters, final String value)
   1.264 +                throws IOException, URISyntaxException, ParseException {
   1.265 +            return new Comment(parameters, value);
   1.266 +        }
   1.267 +
   1.268 +        public Property createProperty(final String name) {
   1.269 +            return new Comment();
   1.270 +        }
   1.271 +    }
   1.272 +
   1.273 +    private static class CompletedFactory implements PropertyFactory {
   1.274 +        private static final long serialVersionUID = 1L;
   1.275 +
   1.276 +        public Property createProperty(final String name,
   1.277 +                final ParameterList parameters, final String value)
   1.278 +                throws IOException, URISyntaxException, ParseException {
   1.279 +            return new Completed(parameters, value);
   1.280 +        }
   1.281 +
   1.282 +        public Property createProperty(final String name) {
   1.283 +            return new Completed();
   1.284 +        }
   1.285 +    }
   1.286 +
   1.287 +    private static class ContactFactory implements PropertyFactory {
   1.288 +        private static final long serialVersionUID = 1L;
   1.289 +
   1.290 +        public Property createProperty(final String name,
   1.291 +                final ParameterList parameters, final String value)
   1.292 +                throws IOException, URISyntaxException, ParseException {
   1.293 +            return new Contact(parameters, value);
   1.294 +        }
   1.295 +
   1.296 +        public Property createProperty(final String name) {
   1.297 +            return new Contact();
   1.298 +        }
   1.299 +    }
   1.300 +
   1.301 +    private static class CountryFactory implements PropertyFactory {
   1.302 +        private static final long serialVersionUID = 1L;
   1.303 +
   1.304 +        public Property createProperty(final String name,
   1.305 +                final ParameterList parameters, final String value)
   1.306 +                throws IOException, URISyntaxException, ParseException {
   1.307 +            return new Country(parameters, value);
   1.308 +        }
   1.309 +
   1.310 +        public Property createProperty(final String name) {
   1.311 +            return new Country();
   1.312 +        }
   1.313 +    }
   1.314 +
   1.315 +    private static class CreatedFactory implements PropertyFactory {
   1.316 +        private static final long serialVersionUID = 1L;
   1.317 +
   1.318 +        public Property createProperty(final String name,
   1.319 +                final ParameterList parameters, final String value)
   1.320 +                throws IOException, URISyntaxException, ParseException {
   1.321 +            return new Created(parameters, value);
   1.322 +        }
   1.323 +
   1.324 +        public Property createProperty(final String name) {
   1.325 +            return new Created();
   1.326 +        }
   1.327 +    }
   1.328 +
   1.329 +    private static class DescriptionFactory implements PropertyFactory {
   1.330 +        private static final long serialVersionUID = 1L;
   1.331 +
   1.332 +        public Property createProperty(final String name,
   1.333 +                final ParameterList parameters, final String value)
   1.334 +                throws IOException, URISyntaxException, ParseException {
   1.335 +            return new Description(parameters, value);
   1.336 +        }
   1.337 +
   1.338 +        public Property createProperty(final String name) {
   1.339 +            return new Description();
   1.340 +        }
   1.341 +    }
   1.342 +
   1.343 +    private static class DtEndFactory implements PropertyFactory {
   1.344 +        private static final long serialVersionUID = 1L;
   1.345 +
   1.346 +        public Property createProperty(final String name,
   1.347 +                final ParameterList parameters, final String value)
   1.348 +                throws IOException, URISyntaxException, ParseException {
   1.349 +            return new DtEnd(parameters, value);
   1.350 +        }
   1.351 +
   1.352 +        public Property createProperty(final String name) {
   1.353 +            return new DtEnd();
   1.354 +        }
   1.355 +    }
   1.356 +
   1.357 +    private static class DtStampFactory implements PropertyFactory {
   1.358 +        private static final long serialVersionUID = 1L;
   1.359 +
   1.360 +        public Property createProperty(final String name,
   1.361 +                final ParameterList parameters, final String value)
   1.362 +                throws IOException, URISyntaxException, ParseException {
   1.363 +            return new DtStamp(parameters, value);
   1.364 +        }
   1.365 +
   1.366 +        public Property createProperty(final String name) {
   1.367 +            return new DtStamp();
   1.368 +        }
   1.369 +    }
   1.370 +
   1.371 +    /**
   1.372 +     * @return
   1.373 +     */
   1.374 +    private static class DtStartFactory implements PropertyFactory {
   1.375 +        private static final long serialVersionUID = 1L;
   1.376 +
   1.377 +        public Property createProperty(final String name,
   1.378 +                final ParameterList parameters, final String value)
   1.379 +                throws IOException, URISyntaxException, ParseException {
   1.380 +            return new DtStart(parameters, value);
   1.381 +        }
   1.382 +
   1.383 +        public Property createProperty(final String name) {
   1.384 +            return new DtStart();
   1.385 +        }
   1.386 +    }
   1.387 +
   1.388 +    private static class DueFactory implements PropertyFactory {
   1.389 +        private static final long serialVersionUID = 1L;
   1.390 +
   1.391 +        public Property createProperty(final String name,
   1.392 +                final ParameterList parameters, final String value)
   1.393 +                throws IOException, URISyntaxException, ParseException {
   1.394 +            return new Due(parameters, value);
   1.395 +        }
   1.396 +
   1.397 +        public Property createProperty(final String name) {
   1.398 +            return new Due();
   1.399 +        }
   1.400 +    }
   1.401 +
   1.402 +    private static class DurationFactory implements PropertyFactory {
   1.403 +        private static final long serialVersionUID = 1L;
   1.404 +
   1.405 +        public Property createProperty(final String name,
   1.406 +                final ParameterList parameters, final String value)
   1.407 +                throws IOException, URISyntaxException, ParseException {
   1.408 +            return new Duration(parameters, value);
   1.409 +        }
   1.410 +
   1.411 +        public Property createProperty(final String name) {
   1.412 +            return new Duration();
   1.413 +        }
   1.414 +    }
   1.415 +
   1.416 +    private static class ExDateFactory implements PropertyFactory {
   1.417 +        private static final long serialVersionUID = 1L;
   1.418 +
   1.419 +        public Property createProperty(final String name,
   1.420 +               final ParameterList parameters, final String value)
   1.421 +                throws IOException, URISyntaxException, ParseException {
   1.422 +            return new ExDate(parameters, value);
   1.423 +        }
   1.424 +
   1.425 +        public Property createProperty(final String name) {
   1.426 +            return new ExDate();
   1.427 +        }
   1.428 +    }
   1.429 +
   1.430 +    private static class ExRuleFactory implements PropertyFactory {
   1.431 +        private static final long serialVersionUID = 1L;
   1.432 +
   1.433 +        public Property createProperty(final String name,
   1.434 +                final ParameterList parameters, final String value)
   1.435 +                throws IOException, URISyntaxException, ParseException {
   1.436 +            return new ExRule(parameters, value);
   1.437 +        }
   1.438 +
   1.439 +        public Property createProperty(final String name) {
   1.440 +            return new ExRule();
   1.441 +        }
   1.442 +    }
   1.443 +
   1.444 +    private static class ExtendedAddressFactory implements PropertyFactory {
   1.445 +        private static final long serialVersionUID = 1L;
   1.446 +
   1.447 +        public Property createProperty(final String name,
   1.448 +                final ParameterList parameters, final String value)
   1.449 +                throws IOException, URISyntaxException, ParseException {
   1.450 +            return new ExtendedAddress(parameters, value);
   1.451 +        }
   1.452 +
   1.453 +        public Property createProperty(final String name) {
   1.454 +            return new ExtendedAddress();
   1.455 +        }
   1.456 +    }
   1.457 +
   1.458 +    private static class FreeBusyFactory implements PropertyFactory {
   1.459 +        private static final long serialVersionUID = 1L;
   1.460 +
   1.461 +        public Property createProperty(final String name,
   1.462 +                final ParameterList parameters, final String value)
   1.463 +                throws IOException, URISyntaxException, ParseException {
   1.464 +            return new FreeBusy(parameters, value);
   1.465 +        }
   1.466 +
   1.467 +        public Property createProperty(final String name) {
   1.468 +            return new FreeBusy();
   1.469 +        }
   1.470 +    }
   1.471 +
   1.472 +    private static class GeoFactory implements PropertyFactory {
   1.473 +        private static final long serialVersionUID = 1L;
   1.474 +
   1.475 +        public Property createProperty(final String name,
   1.476 +                final ParameterList parameters, final String value)
   1.477 +                throws IOException, URISyntaxException, ParseException {
   1.478 +            return new Geo(parameters, value);
   1.479 +        }
   1.480 +
   1.481 +        public Property createProperty(final String name) {
   1.482 +            return new Geo();
   1.483 +        }
   1.484 +    }
   1.485 +
   1.486 +    private static class LastModifiedFactory implements PropertyFactory {
   1.487 +        private static final long serialVersionUID = 1L;
   1.488 +
   1.489 +        public Property createProperty(final String name,
   1.490 +                final ParameterList parameters, final String value)
   1.491 +                throws IOException, URISyntaxException, ParseException {
   1.492 +            return new LastModified(parameters, value);
   1.493 +        }
   1.494 +
   1.495 +        public Property createProperty(final String name) {
   1.496 +            return new LastModified();
   1.497 +        }
   1.498 +    }
   1.499 +
   1.500 +    private static class LocalityFactory implements PropertyFactory {
   1.501 +        private static final long serialVersionUID = 1L;
   1.502 +
   1.503 +        public Property createProperty(final String name,
   1.504 +                final ParameterList parameters, final String value)
   1.505 +                throws IOException, URISyntaxException, ParseException {
   1.506 +            return new Locality(parameters, value);
   1.507 +        }
   1.508 +
   1.509 +        public Property createProperty(final String name) {
   1.510 +            return new Locality();
   1.511 +        }
   1.512 +    }
   1.513 +
   1.514 +    private static class LocationFactory implements PropertyFactory {
   1.515 +        private static final long serialVersionUID = 1L;
   1.516 +
   1.517 +        public Property createProperty(final String name,
   1.518 +                final ParameterList parameters, final String value)
   1.519 +                throws IOException, URISyntaxException, ParseException {
   1.520 +            return new Location(parameters, value);
   1.521 +        }
   1.522 +
   1.523 +        public Property createProperty(final String name) {
   1.524 +            return new Location();
   1.525 +        }
   1.526 +    }
   1.527 +
   1.528 +    private static class LocationTypeFactory implements PropertyFactory {
   1.529 +        private static final long serialVersionUID = 1L;
   1.530 +
   1.531 +        public Property createProperty(final String name,
   1.532 +                final ParameterList parameters, final String value)
   1.533 +                throws IOException, URISyntaxException, ParseException {
   1.534 +            return new LocationType(parameters, value);
   1.535 +        }
   1.536 +
   1.537 +        public Property createProperty(final String name) {
   1.538 +            return new LocationType();
   1.539 +        }
   1.540 +    }
   1.541 +
   1.542 +    private static class MethodFactory implements PropertyFactory {
   1.543 +        private static final long serialVersionUID = 1L;
   1.544 +
   1.545 +        public Property createProperty(final String name,
   1.546 +                final ParameterList parameters, final String value)
   1.547 +                throws IOException, URISyntaxException, ParseException {
   1.548 +            return new Method(parameters, value);
   1.549 +        }
   1.550 +
   1.551 +        public Property createProperty(final String name) {
   1.552 +            return new Method();
   1.553 +        }
   1.554 +    }
   1.555 +
   1.556 +    private static class NameFactory implements PropertyFactory {
   1.557 +        private static final long serialVersionUID = 1L;
   1.558 +
   1.559 +        public Property createProperty(final String name,
   1.560 +                final ParameterList parameters, final String value)
   1.561 +                throws IOException, URISyntaxException, ParseException {
   1.562 +            return new Name(parameters, value);
   1.563 +        }
   1.564 +
   1.565 +        public Property createProperty(final String name) {
   1.566 +            return new Name();
   1.567 +        }
   1.568 +    }
   1.569 +
   1.570 +    private static class OrganizerFactory implements PropertyFactory {
   1.571 +        private static final long serialVersionUID = 1L;
   1.572 +
   1.573 +        public Property createProperty(final String name,
   1.574 +                final ParameterList parameters, final String value)
   1.575 +                throws IOException, URISyntaxException, ParseException {
   1.576 +            return new Organizer(parameters, value);
   1.577 +        }
   1.578 +
   1.579 +        public Property createProperty(final String name) {
   1.580 +            return new Organizer();
   1.581 +        }
   1.582 +    }
   1.583 +
   1.584 +    private static class PercentCompleteFactory implements PropertyFactory {
   1.585 +        private static final long serialVersionUID = 1L;
   1.586 +
   1.587 +        public Property createProperty(final String name,
   1.588 +                final ParameterList parameters, final String value)
   1.589 +                throws IOException, URISyntaxException, ParseException {
   1.590 +            return new PercentComplete(parameters, value);
   1.591 +        }
   1.592 +
   1.593 +        public Property createProperty(final String name) {
   1.594 +            return new PercentComplete();
   1.595 +        }
   1.596 +    }
   1.597 +
   1.598 +    private static class PostalcodeFactory implements PropertyFactory {
   1.599 +        private static final long serialVersionUID = 1L;
   1.600 +
   1.601 +        public Property createProperty(final String name,
   1.602 +                final ParameterList parameters, final String value)
   1.603 +                throws IOException, URISyntaxException, ParseException {
   1.604 +            return new Postalcode(parameters, value);
   1.605 +        }
   1.606 +
   1.607 +        public Property createProperty(final String name) {
   1.608 +            return new Postalcode();
   1.609 +        }
   1.610 +    }
   1.611 +
   1.612 +    private static class PriorityFactory implements PropertyFactory {
   1.613 +        private static final long serialVersionUID = 1L;
   1.614 +
   1.615 +        public Property createProperty(final String name,
   1.616 +                final ParameterList parameters, final String value)
   1.617 +                throws IOException, URISyntaxException, ParseException {
   1.618 +            return new Priority(parameters, value);
   1.619 +        }
   1.620 +
   1.621 +        public Property createProperty(final String name) {
   1.622 +            return new Priority();
   1.623 +        }
   1.624 +    }
   1.625 +
   1.626 +    private static class ProdIdFactory implements PropertyFactory {
   1.627 +        private static final long serialVersionUID = 1L;
   1.628 +
   1.629 +        public Property createProperty(final String name,
   1.630 +                final ParameterList parameters, final String value)
   1.631 +                throws IOException, URISyntaxException, ParseException {
   1.632 +            return new ProdId(parameters, value);
   1.633 +        }
   1.634 +
   1.635 +        public Property createProperty(final String name) {
   1.636 +            return new ProdId();
   1.637 +        }
   1.638 +    }
   1.639 +
   1.640 +    private static class RDateFactory implements PropertyFactory {
   1.641 +        private static final long serialVersionUID = 1L;
   1.642 +
   1.643 +        public Property createProperty(final String name,
   1.644 +                final ParameterList parameters, final String value)
   1.645 +                throws IOException, URISyntaxException, ParseException {
   1.646 +            return new RDate(parameters, value);
   1.647 +        }
   1.648 +
   1.649 +        public Property createProperty(final String name) {
   1.650 +            return new RDate();
   1.651 +        }
   1.652 +    }
   1.653 +
   1.654 +    private static class RecurrenceIdFactory implements PropertyFactory {
   1.655 +        private static final long serialVersionUID = 1L;
   1.656 +
   1.657 +        public Property createProperty(final String name,
   1.658 +                final ParameterList parameters, final String value)
   1.659 +                throws IOException, URISyntaxException, ParseException {
   1.660 +            return new RecurrenceId(parameters, value);
   1.661 +        }
   1.662 +
   1.663 +        public Property createProperty(final String name) {
   1.664 +            return new RecurrenceId();
   1.665 +        }
   1.666 +    }
   1.667 +
   1.668 +    private static class RegionFactory implements PropertyFactory {
   1.669 +        private static final long serialVersionUID = 1L;
   1.670 +
   1.671 +        public Property createProperty(final String name,
   1.672 +                final ParameterList parameters, final String value)
   1.673 +                throws IOException, URISyntaxException, ParseException {
   1.674 +            return new Region(parameters, value);
   1.675 +        }
   1.676 +
   1.677 +        public Property createProperty(final String name) {
   1.678 +            return new Region();
   1.679 +        }
   1.680 +    }
   1.681 +
   1.682 +    private static class RelatedToFactory implements PropertyFactory {
   1.683 +        private static final long serialVersionUID = 1L;
   1.684 +
   1.685 +        public Property createProperty(final String name,
   1.686 +                final ParameterList parameters, final String value)
   1.687 +                throws IOException, URISyntaxException, ParseException {
   1.688 +            return new RelatedTo(parameters, value);
   1.689 +        }
   1.690 +
   1.691 +        public Property createProperty(final String name) {
   1.692 +            return new RelatedTo();
   1.693 +        }
   1.694 +    }
   1.695 +
   1.696 +    private static class RepeatFactory implements PropertyFactory {
   1.697 +        private static final long serialVersionUID = 1L;
   1.698 +
   1.699 +        public Property createProperty(final String name,
   1.700 +                final ParameterList parameters, final String value)
   1.701 +                throws IOException, URISyntaxException, ParseException {
   1.702 +            return new Repeat(parameters, value);
   1.703 +        }
   1.704 +
   1.705 +        public Property createProperty(final String name) {
   1.706 +            return new Repeat();
   1.707 +        }
   1.708 +    }
   1.709 +
   1.710 +    private static class RequestStatusFactory implements PropertyFactory {
   1.711 +        private static final long serialVersionUID = 1L;
   1.712 +
   1.713 +        public Property createProperty(final String name,
   1.714 +                final ParameterList parameters, final String value)
   1.715 +                throws IOException, URISyntaxException, ParseException {
   1.716 +            return new RequestStatus(parameters, value);
   1.717 +        }
   1.718 +
   1.719 +        public Property createProperty(final String name) {
   1.720 +            return new RequestStatus();
   1.721 +        }
   1.722 +    }
   1.723 +
   1.724 +    private static class ResourcesFactory implements PropertyFactory {
   1.725 +        private static final long serialVersionUID = 1L;
   1.726 +
   1.727 +        public Property createProperty(final String name,
   1.728 +                final ParameterList parameters, final String value)
   1.729 +                throws IOException, URISyntaxException, ParseException {
   1.730 +            return new Resources(parameters, value);
   1.731 +        }
   1.732 +
   1.733 +        public Property createProperty(final String name) {
   1.734 +            return new Resources();
   1.735 +        }
   1.736 +    }
   1.737 +
   1.738 +    private static class RRuleFactory implements PropertyFactory {
   1.739 +        private static final long serialVersionUID = 1L;
   1.740 +
   1.741 +        public Property createProperty(final String name,
   1.742 +                final ParameterList parameters, final String value)
   1.743 +                throws IOException, URISyntaxException, ParseException {
   1.744 +            return new RRule(parameters, value);
   1.745 +        }
   1.746 +
   1.747 +        public Property createProperty(final String name) {
   1.748 +            return new RRule();
   1.749 +        }
   1.750 +    }
   1.751 +
   1.752 +    private static class SequenceFactory implements PropertyFactory {
   1.753 +        private static final long serialVersionUID = 1L;
   1.754 +
   1.755 +        public Property createProperty(final String name,
   1.756 +                final ParameterList parameters, final String value)
   1.757 +                throws IOException, URISyntaxException, ParseException {
   1.758 +            return new Sequence(parameters, value);
   1.759 +        }
   1.760 +
   1.761 +        public Property createProperty(final String name) {
   1.762 +            return new Sequence();
   1.763 +        }
   1.764 +    }
   1.765 +
   1.766 +    private static class StatusFactory implements PropertyFactory {
   1.767 +        private static final long serialVersionUID = 1L;
   1.768 +
   1.769 +        public Property createProperty(final String name,
   1.770 +                final ParameterList parameters, final String value)
   1.771 +                throws IOException, URISyntaxException, ParseException {
   1.772 +            return new Status(parameters, value);
   1.773 +        }
   1.774 +
   1.775 +        public Property createProperty(final String name) {
   1.776 +            return new Status();
   1.777 +        }
   1.778 +    }
   1.779 +
   1.780 +    private static class StreetAddressFactory implements PropertyFactory {
   1.781 +        private static final long serialVersionUID = 1L;
   1.782 +
   1.783 +        public Property createProperty(final String name,
   1.784 +                final ParameterList parameters, final String value)
   1.785 +                throws IOException, URISyntaxException, ParseException {
   1.786 +            return new StreetAddress(parameters, value);
   1.787 +        }
   1.788 +
   1.789 +        public Property createProperty(final String name) {
   1.790 +            return new StreetAddress();
   1.791 +        }
   1.792 +    }
   1.793 +
   1.794 +    private static class SummaryFactory implements PropertyFactory {
   1.795 +        private static final long serialVersionUID = 1L;
   1.796 +
   1.797 +        public Property createProperty(final String name,
   1.798 +                final ParameterList parameters, final String value)
   1.799 +                throws IOException, URISyntaxException, ParseException {
   1.800 +            return new Summary(parameters, value);
   1.801 +        }
   1.802 +
   1.803 +        public Property createProperty(final String name) {
   1.804 +            return new Summary();
   1.805 +        }
   1.806 +    }
   1.807 +
   1.808 +    private static class TelFactory implements PropertyFactory {
   1.809 +        private static final long serialVersionUID = 1L;
   1.810 +
   1.811 +        public Property createProperty(final String name,
   1.812 +                final ParameterList parameters, final String value)
   1.813 +                throws IOException, URISyntaxException, ParseException {
   1.814 +            return new Tel(parameters, value);
   1.815 +        }
   1.816 +
   1.817 +        public Property createProperty(final String name) {
   1.818 +            return new Tel();
   1.819 +        }
   1.820 +    }
   1.821 +
   1.822 +    private static class TranspFactory implements PropertyFactory {
   1.823 +        private static final long serialVersionUID = 1L;
   1.824 +
   1.825 +        public Property createProperty(final String name,
   1.826 +                final ParameterList parameters, final String value)
   1.827 +                throws IOException, URISyntaxException, ParseException {
   1.828 +            return new Transp(parameters, value);
   1.829 +        }
   1.830 +
   1.831 +        public Property createProperty(final String name) {
   1.832 +            return new Transp();
   1.833 +        }
   1.834 +    }
   1.835 +
   1.836 +    private static class TriggerFactory implements PropertyFactory {
   1.837 +        private static final long serialVersionUID = 1L;
   1.838 +
   1.839 +        public Property createProperty(final String name,
   1.840 +                final ParameterList parameters, final String value)
   1.841 +                throws IOException, URISyntaxException, ParseException {
   1.842 +            return new Trigger(parameters, value);
   1.843 +        }
   1.844 +
   1.845 +        public Property createProperty(final String name) {
   1.846 +            return new Trigger();
   1.847 +        }
   1.848 +    }
   1.849 +
   1.850 +    private static class TzIdFactory implements PropertyFactory {
   1.851 +        private static final long serialVersionUID = 1L;
   1.852 +
   1.853 +        public Property createProperty(final String name,
   1.854 +                final ParameterList parameters, final String value)
   1.855 +                throws IOException, URISyntaxException, ParseException {
   1.856 +            return new TzId(parameters, value);
   1.857 +        }
   1.858 +
   1.859 +        public Property createProperty(final String name) {
   1.860 +            return new TzId();
   1.861 +        }
   1.862 +    }
   1.863 +
   1.864 +    private static class TzNameFactory implements PropertyFactory {
   1.865 +        private static final long serialVersionUID = 1L;
   1.866 +
   1.867 +        public Property createProperty(final String name,
   1.868 +                final ParameterList parameters, final String value)
   1.869 +                throws IOException, URISyntaxException, ParseException {
   1.870 +            return new TzName(parameters, value);
   1.871 +        }
   1.872 +
   1.873 +        public Property createProperty(final String name) {
   1.874 +            return new TzName();
   1.875 +        }
   1.876 +    }
   1.877 +
   1.878 +    private static class TzOffsetFromFactory implements PropertyFactory {
   1.879 +        private static final long serialVersionUID = 1L;
   1.880 +
   1.881 +        public Property createProperty(final String name,
   1.882 +                final ParameterList parameters, final String value)
   1.883 +                throws IOException, URISyntaxException, ParseException {
   1.884 +            return new TzOffsetFrom(parameters, value);
   1.885 +        }
   1.886 +
   1.887 +        public Property createProperty(final String name) {
   1.888 +            return new TzOffsetFrom();
   1.889 +        }
   1.890 +    }
   1.891 +
   1.892 +    private static class TzOffsetToFactory implements PropertyFactory {
   1.893 +        private static final long serialVersionUID = 1L;
   1.894 +
   1.895 +        public Property createProperty(final String name,
   1.896 +                final ParameterList parameters, final String value)
   1.897 +                throws IOException, URISyntaxException, ParseException {
   1.898 +            return new TzOffsetTo(parameters, value);
   1.899 +        }
   1.900 +
   1.901 +        public Property createProperty(final String name) {
   1.902 +            return new TzOffsetTo();
   1.903 +        }
   1.904 +    }
   1.905 +
   1.906 +    private static class TzUrlFactory implements PropertyFactory {
   1.907 +        private static final long serialVersionUID = 1L;
   1.908 +
   1.909 +        public Property createProperty(final String name,
   1.910 +                final ParameterList parameters, final String value)
   1.911 +                throws IOException, URISyntaxException, ParseException {
   1.912 +            return new TzUrl(parameters, value);
   1.913 +        }
   1.914 +
   1.915 +        public Property createProperty(final String name) {
   1.916 +            return new TzUrl();
   1.917 +        }
   1.918 +    }
   1.919 +
   1.920 +    private static class UidFactory implements PropertyFactory {
   1.921 +        private static final long serialVersionUID = 1L;
   1.922 +
   1.923 +        public Property createProperty(final String name,
   1.924 +                final ParameterList parameters, final String value)
   1.925 +                throws IOException, URISyntaxException, ParseException {
   1.926 +            return new Uid(parameters, value);
   1.927 +        }
   1.928 +
   1.929 +        public Property createProperty(final String name) {
   1.930 +            return new Uid();
   1.931 +        }
   1.932 +    }
   1.933 +
   1.934 +    private static class UrlFactory implements PropertyFactory {
   1.935 +        private static final long serialVersionUID = 1L;
   1.936 +
   1.937 +        public Property createProperty(final String name,
   1.938 +                final ParameterList parameters, final String value)
   1.939 +                throws IOException, URISyntaxException, ParseException {
   1.940 +            return new Url(parameters, value);
   1.941 +        }
   1.942 +
   1.943 +        public Property createProperty(final String name) {
   1.944 +            return new Url();
   1.945 +        }
   1.946 +    }
   1.947 +
   1.948 +    private static class VersionFactory implements PropertyFactory {
   1.949 +        private static final long serialVersionUID = 1L;
   1.950 +
   1.951 +        public Property createProperty(final String name,
   1.952 +                final ParameterList parameters, final String value)
   1.953 +                throws IOException, URISyntaxException, ParseException {
   1.954 +            return new Version(parameters, value);
   1.955 +        }
   1.956 +
   1.957 +        public Property createProperty(final String name) {
   1.958 +            return new Version();
   1.959 +        }
   1.960 +    }
   1.961 +
   1.962 +    /**
   1.963 +     * @return Returns the instance.
   1.964 +     */
   1.965 +    public static PropertyFactoryImpl getInstance() {
   1.966 +        return instance;
   1.967 +    }
   1.968 +
   1.969 +    /**
   1.970 +     * {@inheritDoc}
   1.971 +     */
   1.972 +    public Property createProperty(final String name) {
   1.973 +        final PropertyFactory factory = (PropertyFactory) getFactory(name);
   1.974 +        if (factory != null) {
   1.975 +            return factory.createProperty(name);
   1.976 +        }
   1.977 +        else if (isExperimentalName(name)) {
   1.978 +            return new XProperty(name);
   1.979 +        }
   1.980 +        else if (allowIllegalNames()) {
   1.981 +            return new XProperty(name);
   1.982 +        }
   1.983 +        else {
   1.984 +            throw new IllegalArgumentException("Illegal property [" + name
   1.985 +                    + "]");
   1.986 +        }
   1.987 +    }
   1.988 +
   1.989 +    /**
   1.990 +     * {@inheritDoc}
   1.991 +     */
   1.992 +    public Property createProperty(final String name,
   1.993 +            final ParameterList parameters, final String value)
   1.994 +            throws IOException, URISyntaxException, ParseException {
   1.995 +
   1.996 +        final PropertyFactory factory = (PropertyFactory) getFactory(name);
   1.997 +        if (factory != null) {
   1.998 +            return factory.createProperty(name, parameters, value);
   1.999 +        }
  1.1000 +        else if (isExperimentalName(name)) {
  1.1001 +            return new XProperty(name, parameters, value);
  1.1002 +        }
  1.1003 +        else if (allowIllegalNames()) {
  1.1004 +            return new XProperty(name, parameters, value);
  1.1005 +        }
  1.1006 +        else {
  1.1007 +            throw new IllegalArgumentException("Illegal property [" + name
  1.1008 +                    + "]");
  1.1009 +        }
  1.1010 +    }
  1.1011 +
  1.1012 +    /**
  1.1013 +     * @param name
  1.1014 +     * @return
  1.1015 +     */
  1.1016 +    private boolean isExperimentalName(final String name) {
  1.1017 +        return name.startsWith(Property.EXPERIMENTAL_PREFIX)
  1.1018 +                && name.length() > Property.EXPERIMENTAL_PREFIX.length();
  1.1019 +    }
  1.1020 +}

mercurial