michael@0: /** michael@0: * Copyright (c) 2012, Ben Fortuna michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * michael@0: * o Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * michael@0: * o Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * o Neither the name of Ben Fortuna nor the names of any other contributors michael@0: * may be used to endorse or promote products derived from this software michael@0: * without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@0: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@0: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF michael@0: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING michael@0: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS michael@0: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: package net.fortuna.ical4j.model; michael@0: michael@0: import java.io.IOException; michael@0: import java.net.URISyntaxException; michael@0: import java.text.ParseException; michael@0: michael@0: import net.fortuna.ical4j.model.property.Action; michael@0: import net.fortuna.ical4j.model.property.Attach; michael@0: import net.fortuna.ical4j.model.property.Attendee; michael@0: import net.fortuna.ical4j.model.property.CalScale; michael@0: import net.fortuna.ical4j.model.property.Categories; michael@0: import net.fortuna.ical4j.model.property.Clazz; michael@0: import net.fortuna.ical4j.model.property.Comment; michael@0: import net.fortuna.ical4j.model.property.Completed; michael@0: import net.fortuna.ical4j.model.property.Contact; michael@0: import net.fortuna.ical4j.model.property.Country; michael@0: import net.fortuna.ical4j.model.property.Created; michael@0: import net.fortuna.ical4j.model.property.Description; michael@0: import net.fortuna.ical4j.model.property.DtEnd; michael@0: import net.fortuna.ical4j.model.property.DtStamp; michael@0: import net.fortuna.ical4j.model.property.DtStart; michael@0: import net.fortuna.ical4j.model.property.Due; michael@0: import net.fortuna.ical4j.model.property.Duration; michael@0: import net.fortuna.ical4j.model.property.ExDate; michael@0: import net.fortuna.ical4j.model.property.ExRule; michael@0: import net.fortuna.ical4j.model.property.ExtendedAddress; michael@0: import net.fortuna.ical4j.model.property.FreeBusy; michael@0: import net.fortuna.ical4j.model.property.Geo; michael@0: import net.fortuna.ical4j.model.property.LastModified; michael@0: import net.fortuna.ical4j.model.property.Locality; michael@0: import net.fortuna.ical4j.model.property.Location; michael@0: import net.fortuna.ical4j.model.property.LocationType; michael@0: import net.fortuna.ical4j.model.property.Method; michael@0: import net.fortuna.ical4j.model.property.Name; michael@0: import net.fortuna.ical4j.model.property.Organizer; michael@0: import net.fortuna.ical4j.model.property.PercentComplete; michael@0: import net.fortuna.ical4j.model.property.Postalcode; michael@0: import net.fortuna.ical4j.model.property.Priority; michael@0: import net.fortuna.ical4j.model.property.ProdId; michael@0: import net.fortuna.ical4j.model.property.RDate; michael@0: import net.fortuna.ical4j.model.property.RRule; michael@0: import net.fortuna.ical4j.model.property.RecurrenceId; michael@0: import net.fortuna.ical4j.model.property.Region; michael@0: import net.fortuna.ical4j.model.property.RelatedTo; michael@0: import net.fortuna.ical4j.model.property.Repeat; michael@0: import net.fortuna.ical4j.model.property.RequestStatus; michael@0: import net.fortuna.ical4j.model.property.Resources; michael@0: import net.fortuna.ical4j.model.property.Sequence; michael@0: import net.fortuna.ical4j.model.property.Status; michael@0: import net.fortuna.ical4j.model.property.StreetAddress; michael@0: import net.fortuna.ical4j.model.property.Summary; michael@0: import net.fortuna.ical4j.model.property.Tel; michael@0: import net.fortuna.ical4j.model.property.Transp; michael@0: import net.fortuna.ical4j.model.property.Trigger; michael@0: import net.fortuna.ical4j.model.property.TzId; michael@0: import net.fortuna.ical4j.model.property.TzName; michael@0: import net.fortuna.ical4j.model.property.TzOffsetFrom; michael@0: import net.fortuna.ical4j.model.property.TzOffsetTo; michael@0: import net.fortuna.ical4j.model.property.TzUrl; michael@0: import net.fortuna.ical4j.model.property.Uid; michael@0: import net.fortuna.ical4j.model.property.Url; michael@0: import net.fortuna.ical4j.model.property.Version; michael@0: import net.fortuna.ical4j.model.property.XProperty; michael@0: michael@0: /** michael@0: * A factory for creating iCalendar properties. Note that if relaxed parsing is enabled (via specifying the system michael@0: * property: icalj.parsing.relaxed=true) illegal property names are allowed. michael@0: * michael@0: * @author Ben Fortuna michael@0: * michael@0: * $Id$ [05-Apr-2004] michael@0: */ michael@0: public class PropertyFactoryImpl extends AbstractContentFactory implements PropertyFactory { michael@0: michael@0: private static final long serialVersionUID = -7174232004486979641L; michael@0: michael@0: private static PropertyFactoryImpl instance = new PropertyFactoryImpl(); michael@0: michael@0: /** michael@0: * Constructor made private to prevent instantiation. michael@0: */ michael@0: protected PropertyFactoryImpl() { michael@0: registerDefaultFactory(Property.ACTION, new ActionFactory()); michael@0: registerDefaultFactory(Property.ATTACH, new AttachFactory()); michael@0: registerDefaultFactory(Property.ATTENDEE, new AttendeeFactory()); michael@0: registerDefaultFactory(Property.CALSCALE, new CalScaleFactory()); michael@0: registerDefaultFactory(Property.CATEGORIES, new CategoriesFactory()); michael@0: registerDefaultFactory(Property.CLASS, new ClazzFactory()); michael@0: registerDefaultFactory(Property.COMMENT, new CommentFactory()); michael@0: registerDefaultFactory(Property.COMPLETED, new CompletedFactory()); michael@0: registerDefaultFactory(Property.CONTACT, new ContactFactory()); michael@0: registerDefaultFactory(Property.COUNTRY, new CountryFactory()); michael@0: registerDefaultFactory(Property.CREATED, new CreatedFactory()); michael@0: registerDefaultFactory(Property.DESCRIPTION, new DescriptionFactory()); michael@0: registerDefaultFactory(Property.DTEND, new DtEndFactory()); michael@0: registerDefaultFactory(Property.DTSTAMP, new DtStampFactory()); michael@0: registerDefaultFactory(Property.DTSTART, new DtStartFactory()); michael@0: registerDefaultFactory(Property.DUE, new DueFactory()); michael@0: registerDefaultFactory(Property.DURATION, new DurationFactory()); michael@0: registerDefaultFactory(Property.EXDATE, new ExDateFactory()); michael@0: registerDefaultFactory(Property.EXRULE, new ExRuleFactory()); michael@0: registerDefaultFactory(Property.EXTENDED_ADDRESS, new ExtendedAddressFactory()); michael@0: registerDefaultFactory(Property.FREEBUSY, new FreeBusyFactory()); michael@0: registerDefaultFactory(Property.GEO, new GeoFactory()); michael@0: registerDefaultFactory(Property.LAST_MODIFIED, new LastModifiedFactory()); michael@0: registerDefaultFactory(Property.LOCALITY, new LocalityFactory()); michael@0: registerDefaultFactory(Property.LOCATION, new LocationFactory()); michael@0: registerDefaultFactory(Property.LOCATION_TYPE, new LocationTypeFactory()); michael@0: registerDefaultFactory(Property.METHOD, new MethodFactory()); michael@0: registerDefaultFactory(Property.NAME, new NameFactory()); michael@0: registerDefaultFactory(Property.ORGANIZER, new OrganizerFactory()); michael@0: registerDefaultFactory(Property.PERCENT_COMPLETE, new PercentCompleteFactory()); michael@0: registerDefaultFactory(Property.POSTALCODE, new PostalcodeFactory()); michael@0: registerDefaultFactory(Property.PRIORITY, new PriorityFactory()); michael@0: registerDefaultFactory(Property.PRODID, new ProdIdFactory()); michael@0: registerDefaultFactory(Property.RDATE, new RDateFactory()); michael@0: registerDefaultFactory(Property.RECURRENCE_ID, new RecurrenceIdFactory()); michael@0: registerDefaultFactory(Property.REGION, new RegionFactory()); michael@0: registerDefaultFactory(Property.RELATED_TO, new RelatedToFactory()); michael@0: registerDefaultFactory(Property.REPEAT, new RepeatFactory()); michael@0: registerDefaultFactory(Property.REQUEST_STATUS, new RequestStatusFactory()); michael@0: registerDefaultFactory(Property.RESOURCES, new ResourcesFactory()); michael@0: registerDefaultFactory(Property.RRULE, new RRuleFactory()); michael@0: registerDefaultFactory(Property.SEQUENCE, new SequenceFactory()); michael@0: registerDefaultFactory(Property.STATUS, new StatusFactory()); michael@0: registerDefaultFactory(Property.STREET_ADDRESS, new StreetAddressFactory()); michael@0: registerDefaultFactory(Property.SUMMARY, new SummaryFactory()); michael@0: registerDefaultFactory(Property.TEL, new TelFactory()); michael@0: registerDefaultFactory(Property.TRANSP, new TranspFactory()); michael@0: registerDefaultFactory(Property.TRIGGER, new TriggerFactory()); michael@0: registerDefaultFactory(Property.TZID, new TzIdFactory()); michael@0: registerDefaultFactory(Property.TZNAME, new TzNameFactory()); michael@0: registerDefaultFactory(Property.TZOFFSETFROM, new TzOffsetFromFactory()); michael@0: registerDefaultFactory(Property.TZOFFSETTO, new TzOffsetToFactory()); michael@0: registerDefaultFactory(Property.TZURL, new TzUrlFactory()); michael@0: registerDefaultFactory(Property.UID, new UidFactory()); michael@0: registerDefaultFactory(Property.URL, new UrlFactory()); michael@0: registerDefaultFactory(Property.VERSION, new VersionFactory()); michael@0: } michael@0: michael@0: private static class ActionFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Action(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Action(); michael@0: } michael@0: } michael@0: michael@0: private static class AttachFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Attach(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Attach(); michael@0: } michael@0: } michael@0: michael@0: private static class AttendeeFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Attendee(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Attendee(); michael@0: } michael@0: } michael@0: michael@0: private static class CalScaleFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new CalScale(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new CalScale(); michael@0: } michael@0: } michael@0: michael@0: private static class CategoriesFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Categories(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Categories(); michael@0: } michael@0: } michael@0: michael@0: private static class ClazzFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Clazz(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Clazz(); michael@0: } michael@0: } michael@0: michael@0: private static class CommentFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Comment(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Comment(); michael@0: } michael@0: } michael@0: michael@0: private static class CompletedFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Completed(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Completed(); michael@0: } michael@0: } michael@0: michael@0: private static class ContactFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Contact(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Contact(); michael@0: } michael@0: } michael@0: michael@0: private static class CountryFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Country(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Country(); michael@0: } michael@0: } michael@0: michael@0: private static class CreatedFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Created(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Created(); michael@0: } michael@0: } michael@0: michael@0: private static class DescriptionFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Description(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Description(); michael@0: } michael@0: } michael@0: michael@0: private static class DtEndFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new DtEnd(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new DtEnd(); michael@0: } michael@0: } michael@0: michael@0: private static class DtStampFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new DtStamp(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new DtStamp(); michael@0: } michael@0: } michael@0: michael@0: private static class DtStartFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new DtStart(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new DtStart(); michael@0: } michael@0: } michael@0: michael@0: private static class DueFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Due(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Due(); michael@0: } michael@0: } michael@0: michael@0: private static class DurationFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Duration(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Duration(); michael@0: } michael@0: } michael@0: michael@0: private static class ExDateFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new ExDate(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new ExDate(); michael@0: } michael@0: } michael@0: michael@0: private static class ExRuleFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new ExRule(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new ExRule(); michael@0: } michael@0: } michael@0: michael@0: private static class ExtendedAddressFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new ExtendedAddress(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new ExtendedAddress(); michael@0: } michael@0: } michael@0: michael@0: private static class FreeBusyFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new FreeBusy(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new FreeBusy(); michael@0: } michael@0: } michael@0: michael@0: private static class GeoFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Geo(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Geo(); michael@0: } michael@0: } michael@0: michael@0: private static class LastModifiedFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new LastModified(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new LastModified(); michael@0: } michael@0: } michael@0: michael@0: private static class LocalityFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Locality(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Locality(); michael@0: } michael@0: } michael@0: michael@0: private static class LocationFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Location(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Location(); michael@0: } michael@0: } michael@0: michael@0: private static class LocationTypeFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new LocationType(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new LocationType(); michael@0: } michael@0: } michael@0: michael@0: private static class MethodFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Method(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Method(); michael@0: } michael@0: } michael@0: michael@0: private static class NameFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Name(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Name(); michael@0: } michael@0: } michael@0: michael@0: private static class OrganizerFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Organizer(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Organizer(); michael@0: } michael@0: } michael@0: michael@0: private static class PercentCompleteFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new PercentComplete(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new PercentComplete(); michael@0: } michael@0: } michael@0: michael@0: private static class PostalcodeFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Postalcode(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Postalcode(); michael@0: } michael@0: } michael@0: michael@0: private static class PriorityFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Priority(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Priority(); michael@0: } michael@0: } michael@0: michael@0: private static class ProdIdFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new ProdId(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new ProdId(); michael@0: } michael@0: } michael@0: michael@0: private static class RDateFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new RDate(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new RDate(); michael@0: } michael@0: } michael@0: michael@0: private static class RecurrenceIdFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new RecurrenceId(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new RecurrenceId(); michael@0: } michael@0: } michael@0: michael@0: private static class RegionFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Region(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Region(); michael@0: } michael@0: } michael@0: michael@0: private static class RelatedToFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new RelatedTo(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new RelatedTo(); michael@0: } michael@0: } michael@0: michael@0: private static class RepeatFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Repeat(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Repeat(); michael@0: } michael@0: } michael@0: michael@0: private static class RequestStatusFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new RequestStatus(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new RequestStatus(); michael@0: } michael@0: } michael@0: michael@0: private static class ResourcesFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Resources(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Resources(); michael@0: } michael@0: } michael@0: michael@0: private static class RRuleFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new RRule(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new RRule(); michael@0: } michael@0: } michael@0: michael@0: private static class SequenceFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Sequence(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Sequence(); michael@0: } michael@0: } michael@0: michael@0: private static class StatusFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Status(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Status(); michael@0: } michael@0: } michael@0: michael@0: private static class StreetAddressFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new StreetAddress(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new StreetAddress(); michael@0: } michael@0: } michael@0: michael@0: private static class SummaryFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Summary(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Summary(); michael@0: } michael@0: } michael@0: michael@0: private static class TelFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Tel(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Tel(); michael@0: } michael@0: } michael@0: michael@0: private static class TranspFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Transp(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Transp(); michael@0: } michael@0: } michael@0: michael@0: private static class TriggerFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Trigger(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Trigger(); michael@0: } michael@0: } michael@0: michael@0: private static class TzIdFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new TzId(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new TzId(); michael@0: } michael@0: } michael@0: michael@0: private static class TzNameFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new TzName(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new TzName(); michael@0: } michael@0: } michael@0: michael@0: private static class TzOffsetFromFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new TzOffsetFrom(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new TzOffsetFrom(); michael@0: } michael@0: } michael@0: michael@0: private static class TzOffsetToFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new TzOffsetTo(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new TzOffsetTo(); michael@0: } michael@0: } michael@0: michael@0: private static class TzUrlFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new TzUrl(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new TzUrl(); michael@0: } michael@0: } michael@0: michael@0: private static class UidFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Uid(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Uid(); michael@0: } michael@0: } michael@0: michael@0: private static class UrlFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Url(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Url(); michael@0: } michael@0: } michael@0: michael@0: private static class VersionFactory implements PropertyFactory { michael@0: private static final long serialVersionUID = 1L; michael@0: michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: return new Version(parameters, value); michael@0: } michael@0: michael@0: public Property createProperty(final String name) { michael@0: return new Version(); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * @return Returns the instance. michael@0: */ michael@0: public static PropertyFactoryImpl getInstance() { michael@0: return instance; michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public Property createProperty(final String name) { michael@0: final PropertyFactory factory = (PropertyFactory) getFactory(name); michael@0: if (factory != null) { michael@0: return factory.createProperty(name); michael@0: } michael@0: else if (isExperimentalName(name)) { michael@0: return new XProperty(name); michael@0: } michael@0: else if (allowIllegalNames()) { michael@0: return new XProperty(name); michael@0: } michael@0: else { michael@0: throw new IllegalArgumentException("Illegal property [" + name michael@0: + "]"); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public Property createProperty(final String name, michael@0: final ParameterList parameters, final String value) michael@0: throws IOException, URISyntaxException, ParseException { michael@0: michael@0: final PropertyFactory factory = (PropertyFactory) getFactory(name); michael@0: if (factory != null) { michael@0: return factory.createProperty(name, parameters, value); michael@0: } michael@0: else if (isExperimentalName(name)) { michael@0: return new XProperty(name, parameters, value); michael@0: } michael@0: else if (allowIllegalNames()) { michael@0: return new XProperty(name, parameters, value); michael@0: } michael@0: else { michael@0: throw new IllegalArgumentException("Illegal property [" + name michael@0: + "]"); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * @param name michael@0: * @return michael@0: */ michael@0: private boolean isExperimentalName(final String name) { michael@0: return name.startsWith(Property.EXPERIMENTAL_PREFIX) michael@0: && name.length() > Property.EXPERIMENTAL_PREFIX.length(); michael@0: } michael@0: }