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

changeset 0
fb9019fb1bf7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/net/fortuna/ical4j/model/property/DtStart.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,205 @@
     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.Date;
    1.40 +import net.fortuna.ical4j.model.ParameterList;
    1.41 +import net.fortuna.ical4j.model.PropertyFactoryImpl;
    1.42 +import net.fortuna.ical4j.model.TimeZone;
    1.43 +import net.fortuna.ical4j.model.ValidationException;
    1.44 +
    1.45 +/**
    1.46 + * $Id$
    1.47 + * 
    1.48 + * Created: [Apr 6, 2004]
    1.49 + *
    1.50 + * Defines a DTSTART iCalendar component property.
    1.51 + * 
    1.52 + * <pre>
    1.53 + *     4.8.2.4 Date/Time Start
    1.54 + *     
    1.55 + *        Property Name: DTSTART
    1.56 + *     
    1.57 + *        Purpose: This property specifies when the calendar component begins.
    1.58 + *     
    1.59 + *        Value Type: The default value type is DATE-TIME. The time value MUST
    1.60 + *        be one of the forms defined for the DATE-TIME value type. The value
    1.61 + *        type can be set to a DATE value type.
    1.62 + *     
    1.63 + *        Property Parameters: Non-standard, value data type, time zone
    1.64 + *        identifier property parameters can be specified on this property.
    1.65 + *     
    1.66 + *        Conformance: This property can be specified in the &quot;VEVENT&quot;, &quot;VTODO&quot;,
    1.67 + *        &quot;VFREEBUSY&quot;, or &quot;VTIMEZONE&quot; calendar components.
    1.68 + *     
    1.69 + *        Description: Within the &quot;VEVENT&quot; calendar component, this property
    1.70 + *        defines the start date and time for the event. The property is
    1.71 + *        REQUIRED in &quot;VEVENT&quot; calendar components. Events can have a start
    1.72 + *        date/time but no end date/time. In that case, the event does not take
    1.73 + *        up any time.
    1.74 + *     
    1.75 + *        Within the &quot;VFREEBUSY&quot; calendar component, this property defines the
    1.76 + *        start date and time for the free or busy time information. The time
    1.77 + *        MUST be specified in UTC time.
    1.78 + *     
    1.79 + *        Within the &quot;VTIMEZONE&quot; calendar component, this property defines the
    1.80 + *        effective start date and time for a time zone specification. This
    1.81 + *        property is REQUIRED within each STANDARD and DAYLIGHT part included
    1.82 + *        in &quot;VTIMEZONE&quot; calendar components and MUST be specified as a local
    1.83 + *        DATE-TIME without the &quot;TZID&quot; property parameter.
    1.84 + *     
    1.85 + *        Format Definition: The property is defined by the following notation:
    1.86 + *     
    1.87 + *          dtstart    = &quot;DTSTART&quot; dtstparam &quot;:&quot; dtstval CRLF
    1.88 + *     
    1.89 + *          dtstparam  = *(
    1.90 + *     
    1.91 + *                     ; the following are optional,
    1.92 + *                     ; but MUST NOT occur more than once
    1.93 + *     
    1.94 + *                     (&quot;;&quot; &quot;VALUE&quot; &quot;=&quot; (&quot;DATE-TIME&quot; / &quot;DATE&quot;)) /
    1.95 + *                     (&quot;;&quot; tzidparam) /
    1.96 + *     
    1.97 + *                     ; the following is optional,
    1.98 + *                     ; and MAY occur more than once
    1.99 + *     
   1.100 + *                       *(&quot;;&quot; xparam)
   1.101 + *     
   1.102 + *                     )
   1.103 + *     
   1.104 + *     
   1.105 + *     
   1.106 + *          dtstval    = date-time / date
   1.107 + *          ;Value MUST match value type
   1.108 + * </pre>
   1.109 + * 
   1.110 + * @author Ben Fortuna
   1.111 + */
   1.112 +public class DtStart extends DateProperty {
   1.113 +
   1.114 +    private static final long serialVersionUID = -5707097476081111815L;
   1.115 +
   1.116 +    /**
   1.117 +     * Default constructor. The time value is initialised to the time of instantiation.
   1.118 +     */
   1.119 +    public DtStart() {
   1.120 +        super(DTSTART, PropertyFactoryImpl.getInstance());
   1.121 +    }
   1.122 +
   1.123 +    /**
   1.124 +     * Creates a new DTSTART property initialised with the specified timezone.
   1.125 +     * @param timezone initial timezone
   1.126 +     */
   1.127 +    public DtStart(TimeZone timezone) {
   1.128 +        super(DTSTART, timezone, PropertyFactoryImpl.getInstance());
   1.129 +    }
   1.130 +
   1.131 +    /**
   1.132 +     * @param aValue a value string for this component
   1.133 +     * @throws ParseException where the specified value string is not a valid date-time/date representation
   1.134 +     */
   1.135 +    public DtStart(final String aValue) throws ParseException {
   1.136 +        super(DTSTART, PropertyFactoryImpl.getInstance());
   1.137 +        setValue(aValue);
   1.138 +    }
   1.139 +
   1.140 +    /**
   1.141 +     * Creates a new DTSTART property initialised with the specified timezone and value.
   1.142 +     * @param value a string representation of a DTSTART value
   1.143 +     * @param timezone initial timezone
   1.144 +     * @throws ParseException where the specified value is not a valid string
   1.145 +     * representation
   1.146 +     */
   1.147 +    public DtStart(String value, TimeZone timezone) throws ParseException {
   1.148 +        super(DTSTART, timezone, PropertyFactoryImpl.getInstance());
   1.149 +        setValue(value);
   1.150 +    }
   1.151 +
   1.152 +    /**
   1.153 +     * @param aList a list of parameters for this component
   1.154 +     * @param aValue a value string for this component
   1.155 +     * @throws ParseException where the specified value string is not a valid date-time/date representation
   1.156 +     */
   1.157 +    public DtStart(final ParameterList aList, final String aValue)
   1.158 +            throws ParseException {
   1.159 +        super(DTSTART, aList, PropertyFactoryImpl.getInstance());
   1.160 +        setValue(aValue);
   1.161 +    }
   1.162 +
   1.163 +    /**
   1.164 +     * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   1.165 +     * @param aDate a date
   1.166 +     */
   1.167 +    public DtStart(final Date aDate) {
   1.168 +        super(DTSTART, PropertyFactoryImpl.getInstance());
   1.169 +        setDate(aDate);
   1.170 +    }
   1.171 +
   1.172 +    /**
   1.173 +     * Constructs a new DtStart with the specified time.
   1.174 +     * @param time the time of the DtStart
   1.175 +     * @param utc specifies whether time is UTC
   1.176 +     */
   1.177 +    public DtStart(final Date time, final boolean utc) {
   1.178 +        super(DTSTART, PropertyFactoryImpl.getInstance());
   1.179 +        setDate(time);
   1.180 +        setUtc(utc);
   1.181 +    }
   1.182 +
   1.183 +    /**
   1.184 +     * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   1.185 +     * @param aList a list of parameters for this component
   1.186 +     * @param aDate a date
   1.187 +     */
   1.188 +    public DtStart(final ParameterList aList, final Date aDate) {
   1.189 +        super(DTSTART, aList, PropertyFactoryImpl.getInstance());
   1.190 +        setDate(aDate);
   1.191 +    }
   1.192 +
   1.193 +    /**
   1.194 +     * {@inheritDoc}
   1.195 +     */
   1.196 +    public final void validate() throws ValidationException {
   1.197 +        super.validate();
   1.198 +
   1.199 +        /*
   1.200 +         * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) /
   1.201 +         * (";" tzidparam) /
   1.202 +         */
   1.203 +
   1.204 +        /*
   1.205 +         * ; the following is optional, ; and MAY occur more than once (";" xparam)
   1.206 +         */
   1.207 +    }
   1.208 +}

mercurial