src/net/fortuna/ical4j/model/property/RDate.java

branch
ICAL4J_EMBED_1
changeset 15
cc93757aeca3
parent 14
5ae3e5665a0b
child 18
6dcaece8ec41
     1.1 --- a/src/net/fortuna/ical4j/model/property/RDate.java	Thu Feb 12 18:02:00 2015 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,266 +0,0 @@
     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.property;
    1.36 -
    1.37 -import java.text.ParseException;
    1.38 -
    1.39 -import net.fortuna.ical4j.model.DateList;
    1.40 -import net.fortuna.ical4j.model.Parameter;
    1.41 -import net.fortuna.ical4j.model.ParameterList;
    1.42 -import net.fortuna.ical4j.model.PeriodList;
    1.43 -import net.fortuna.ical4j.model.PropertyFactoryImpl;
    1.44 -import net.fortuna.ical4j.model.TimeZone;
    1.45 -import net.fortuna.ical4j.model.ValidationException;
    1.46 -import net.fortuna.ical4j.model.parameter.Value;
    1.47 -import net.fortuna.ical4j.util.ParameterValidator;
    1.48 -import net.fortuna.ical4j.util.Strings;
    1.49 -
    1.50 -/**
    1.51 - * $Id$
    1.52 - * 
    1.53 - * Created: [Apr 6, 2004]
    1.54 - *
    1.55 - * Defines an RDATE iCalendar component property.
    1.56 - * 
    1.57 - * <pre>
    1.58 - *     4.8.5.3 Recurrence Date/Times
    1.59 - *     
    1.60 - *        Property Name: RDATE
    1.61 - *     
    1.62 - *        Purpose: This property defines the list of date/times for a
    1.63 - *        recurrence set.
    1.64 - *     
    1.65 - *        Value Type: The default value type for this property is DATE-TIME.
    1.66 - *        The value type can be set to DATE or PERIOD.
    1.67 - *     
    1.68 - *        Property Parameters: Non-standard, value data type and time zone
    1.69 - *        identifier property parameters can be specified on this property.
    1.70 - *     
    1.71 - *        Conformance: The property can be specified in &quot;VEVENT&quot;, &quot;VTODO&quot;,
    1.72 - *        &quot;VJOURNAL&quot; or &quot;VTIMEZONE&quot; calendar components.
    1.73 - *     
    1.74 - *        Description: This property can appear along with the &quot;RRULE&quot; property
    1.75 - *        to define an aggregate set of repeating occurrences. When they both
    1.76 - *        appear in an iCalendar object, the recurring events are defined by
    1.77 - *        the union of occurrences defined by both the &quot;RDATE&quot; and &quot;RRULE&quot;.
    1.78 - *     
    1.79 - *        The recurrence dates, if specified, are used in computing the
    1.80 - *        recurrence set. The recurrence set is the complete set of recurrence
    1.81 - *        instances for a calendar component. The recurrence set is generated
    1.82 - *        by considering the initial &quot;DTSTART&quot; property along with the &quot;RRULE&quot;,
    1.83 - *        &quot;RDATE&quot;, &quot;EXDATE&quot; and &quot;EXRULE&quot; properties contained within the
    1.84 - *        iCalendar object. The &quot;DTSTART&quot; property defines the first instance
    1.85 - *        in the recurrence set. Multiple instances of the &quot;RRULE&quot; and &quot;EXRULE&quot;
    1.86 - *        properties can also be specified to define more sophisticated
    1.87 - *        recurrence sets. The final recurrence set is generated by gathering
    1.88 - *        all of the start date/times generated by any of the specified &quot;RRULE&quot;
    1.89 - *        and &quot;RDATE&quot; properties, and excluding any start date/times which fall
    1.90 - *        within the union of start date/times generated by any specified
    1.91 - *        &quot;EXRULE&quot; and &quot;EXDATE&quot; properties. This implies that start date/times
    1.92 - *        within exclusion related properties (i.e., &quot;EXDATE&quot; and &quot;EXRULE&quot;)
    1.93 - *        take precedence over those specified by inclusion properties (i.e.,
    1.94 - *        &quot;RDATE&quot; and &quot;RRULE&quot;). Where duplicate instances are generated by the
    1.95 - *        &quot;RRULE&quot; and &quot;RDATE&quot; properties, only one recurrence is considered.
    1.96 - *        Duplicate instances are ignored.
    1.97 - *     
    1.98 - *        Format Definition: The property is defined by the following notation:
    1.99 - *     
   1.100 - *          rdate      = &quot;RDATE&quot; rdtparam &quot;:&quot; rdtval *(&quot;,&quot; rdtval) CRLF
   1.101 - *     
   1.102 - *          rdtparam   = *(
   1.103 - *     
   1.104 - *                     ; the following are optional,
   1.105 - *                     ; but MUST NOT occur more than once
   1.106 - *     
   1.107 - *                     (&quot;;&quot; &quot;VALUE&quot; &quot;=&quot; (&quot;DATE-TIME&quot;
   1.108 - *                      / &quot;DATE&quot; / &quot;PERIOD&quot;)) /
   1.109 - *                     (&quot;;&quot; tzidparam) /
   1.110 - *     
   1.111 - *                     ; the following is optional,
   1.112 - *                     ; and MAY occur more than once
   1.113 - *     
   1.114 - *                     (&quot;;&quot; xparam)
   1.115 - *     
   1.116 - *                     )
   1.117 - *     
   1.118 - *          rdtval     = date-time / date / period
   1.119 - *          ;Value MUST match value type
   1.120 - *     
   1.121 - *        Example: The following are examples of this property:
   1.122 - *     
   1.123 - *          RDATE:19970714T123000Z
   1.124 - *     
   1.125 - *          RDATE;TZID=US-EASTERN:19970714T083000
   1.126 - *     
   1.127 - *          RDATE;VALUE=PERIOD:19960403T020000Z/19960403T040000Z,
   1.128 - *           19960404T010000Z/PT3H
   1.129 - *     
   1.130 - *          RDATE;VALUE=DATE:19970101,19970120,19970217,19970421
   1.131 - *           19970526,19970704,19970901,19971014,19971128,19971129,19971225
   1.132 - * </pre>
   1.133 - * 
   1.134 - * @author Ben Fortuna
   1.135 - */
   1.136 -public class RDate extends DateListProperty {
   1.137 -
   1.138 -    private static final long serialVersionUID = -3320381650013860193L;
   1.139 -
   1.140 -    private PeriodList periods;
   1.141 -
   1.142 -    /**
   1.143 -     * Default constructor.
   1.144 -     */
   1.145 -    public RDate() {
   1.146 -        super(RDATE, PropertyFactoryImpl.getInstance());
   1.147 -        periods = new PeriodList(false, true);
   1.148 -    }
   1.149 -
   1.150 -    /**
   1.151 -     * @param aList a list of parameters for this component
   1.152 -     * @param aValue a value string for this component
   1.153 -     * @throws ParseException where the specified value string is not a valid date-time/date representation
   1.154 -     */
   1.155 -    public RDate(final ParameterList aList, final String aValue)
   1.156 -            throws ParseException {
   1.157 -        super(RDATE, aList, PropertyFactoryImpl.getInstance());
   1.158 -        periods = new PeriodList(false, true);
   1.159 -        setValue(aValue);
   1.160 -    }
   1.161 -
   1.162 -    /**
   1.163 -     * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   1.164 -     * @param dates a list of dates
   1.165 -     */
   1.166 -    public RDate(final DateList dates) {
   1.167 -        super(RDATE, dates, PropertyFactoryImpl.getInstance());
   1.168 -        periods = new PeriodList(false, true);
   1.169 -    }
   1.170 -
   1.171 -    /**
   1.172 -     * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   1.173 -     * @param aList a list of parameters for this component
   1.174 -     * @param dates a list of dates
   1.175 -     */
   1.176 -    public RDate(final ParameterList aList, final DateList dates) {
   1.177 -        super(RDATE, aList, dates, PropertyFactoryImpl.getInstance());
   1.178 -        periods = new PeriodList(false, true);
   1.179 -    }
   1.180 -
   1.181 -    /**
   1.182 -     * Constructor.
   1.183 -     * @param periods a list of periods
   1.184 -     */
   1.185 -    public RDate(final PeriodList periods) {
   1.186 -        super(RDATE, new DateList(true), PropertyFactoryImpl.getInstance());
   1.187 -        this.periods = periods;
   1.188 -    }
   1.189 -
   1.190 -    /**
   1.191 -     * Constructor.
   1.192 -     * @param aList a list of parameters for this component
   1.193 -     * @param periods a list of periods
   1.194 -     */
   1.195 -    public RDate(final ParameterList aList, final PeriodList periods) {
   1.196 -        super(RDATE, aList, new DateList(true), PropertyFactoryImpl.getInstance());
   1.197 -        this.periods = periods;
   1.198 -    }
   1.199 -
   1.200 -    /**
   1.201 -     * {@inheritDoc}
   1.202 -     */
   1.203 -    public final void validate() throws ValidationException {
   1.204 -
   1.205 -        /*
   1.206 -         * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE" /
   1.207 -         * "PERIOD")) / (";" tzidparam) /
   1.208 -         */
   1.209 -        ParameterValidator.getInstance().assertOneOrLess(Parameter.VALUE,
   1.210 -                getParameters());
   1.211 -
   1.212 -        final Parameter valueParam = getParameter(Parameter.VALUE);
   1.213 -
   1.214 -        if (valueParam != null && !Value.DATE_TIME.equals(valueParam)
   1.215 -                && !Value.DATE.equals(valueParam)
   1.216 -                && !Value.PERIOD.equals(valueParam)) {
   1.217 -            throw new ValidationException("Parameter [" + Parameter.VALUE
   1.218 -                    + "] is invalid");
   1.219 -        }
   1.220 -
   1.221 -        ParameterValidator.getInstance().assertOneOrLess(Parameter.TZID,
   1.222 -                getParameters());
   1.223 -
   1.224 -        /*
   1.225 -         * ; the following is optional, ; and MAY occur more than once (";" xparam)
   1.226 -         */
   1.227 -    }
   1.228 -
   1.229 -    /**
   1.230 -     * @return Returns the period list.
   1.231 -     */
   1.232 -    public final PeriodList getPeriods() {
   1.233 -        return periods;
   1.234 -    }
   1.235 -
   1.236 -    /**
   1.237 -     * {@inheritDoc}
   1.238 -     */
   1.239 -    public final void setValue(final String aValue) throws ParseException {
   1.240 -        if (Value.PERIOD.equals(getParameter(Parameter.VALUE))) {
   1.241 -            periods = new PeriodList(aValue);
   1.242 -        }
   1.243 -        else {
   1.244 -            super.setValue(aValue);
   1.245 -        }
   1.246 -    }
   1.247 -
   1.248 -    /**
   1.249 -     * {@inheritDoc}
   1.250 -     */
   1.251 -    public final String getValue() {
   1.252 -        if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) {
   1.253 -            return Strings.valueOf(getPeriods());
   1.254 -        }
   1.255 -        return super.getValue();
   1.256 -    }
   1.257 -    
   1.258 -    /**
   1.259 -     * {@inheritDoc}
   1.260 -     */
   1.261 -    public final void setTimeZone(TimeZone timezone) {
   1.262 -        if (periods != null && !(periods.isEmpty() && periods.isUnmodifiable())) {
   1.263 -            periods.setTimeZone(timezone);
   1.264 -        }
   1.265 -        else {
   1.266 -            super.setTimeZone(timezone);
   1.267 -        }
   1.268 -    }
   1.269 -}

mercurial