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

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

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

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

     1 /**
     2  * Copyright (c) 2012, Ben Fortuna
     3  * All rights reserved.
     4  *
     5  * Redistribution and use in source and binary forms, with or without
     6  * modification, are permitted provided that the following conditions
     7  * are met:
     8  *
     9  *  o Redistributions of source code must retain the above copyright
    10  * notice, this list of conditions and the following disclaimer.
    11  *
    12  *  o Redistributions in binary form must reproduce the above copyright
    13  * notice, this list of conditions and the following disclaimer in the
    14  * documentation and/or other materials provided with the distribution.
    15  *
    16  *  o Neither the name of Ben Fortuna nor the names of any other contributors
    17  * may be used to endorse or promote products derived from this software
    18  * without specific prior written permission.
    19  *
    20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    31  */
    32 package net.fortuna.ical4j.model.property;
    34 import java.text.ParseException;
    36 import net.fortuna.ical4j.model.Date;
    37 import net.fortuna.ical4j.model.ParameterList;
    38 import net.fortuna.ical4j.model.PropertyFactoryImpl;
    39 import net.fortuna.ical4j.model.TimeZone;
    40 import net.fortuna.ical4j.model.ValidationException;
    42 /**
    43  * $Id$
    44  * 
    45  * Created: [Apr 6, 2004]
    46  *
    47  * Defines a DTSTART iCalendar component property.
    48  * 
    49  * <pre>
    50  *     4.8.2.4 Date/Time Start
    51  *     
    52  *        Property Name: DTSTART
    53  *     
    54  *        Purpose: This property specifies when the calendar component begins.
    55  *     
    56  *        Value Type: The default value type is DATE-TIME. The time value MUST
    57  *        be one of the forms defined for the DATE-TIME value type. The value
    58  *        type can be set to a DATE value type.
    59  *     
    60  *        Property Parameters: Non-standard, value data type, time zone
    61  *        identifier property parameters can be specified on this property.
    62  *     
    63  *        Conformance: This property can be specified in the &quot;VEVENT&quot;, &quot;VTODO&quot;,
    64  *        &quot;VFREEBUSY&quot;, or &quot;VTIMEZONE&quot; calendar components.
    65  *     
    66  *        Description: Within the &quot;VEVENT&quot; calendar component, this property
    67  *        defines the start date and time for the event. The property is
    68  *        REQUIRED in &quot;VEVENT&quot; calendar components. Events can have a start
    69  *        date/time but no end date/time. In that case, the event does not take
    70  *        up any time.
    71  *     
    72  *        Within the &quot;VFREEBUSY&quot; calendar component, this property defines the
    73  *        start date and time for the free or busy time information. The time
    74  *        MUST be specified in UTC time.
    75  *     
    76  *        Within the &quot;VTIMEZONE&quot; calendar component, this property defines the
    77  *        effective start date and time for a time zone specification. This
    78  *        property is REQUIRED within each STANDARD and DAYLIGHT part included
    79  *        in &quot;VTIMEZONE&quot; calendar components and MUST be specified as a local
    80  *        DATE-TIME without the &quot;TZID&quot; property parameter.
    81  *     
    82  *        Format Definition: The property is defined by the following notation:
    83  *     
    84  *          dtstart    = &quot;DTSTART&quot; dtstparam &quot;:&quot; dtstval CRLF
    85  *     
    86  *          dtstparam  = *(
    87  *     
    88  *                     ; the following are optional,
    89  *                     ; but MUST NOT occur more than once
    90  *     
    91  *                     (&quot;;&quot; &quot;VALUE&quot; &quot;=&quot; (&quot;DATE-TIME&quot; / &quot;DATE&quot;)) /
    92  *                     (&quot;;&quot; tzidparam) /
    93  *     
    94  *                     ; the following is optional,
    95  *                     ; and MAY occur more than once
    96  *     
    97  *                       *(&quot;;&quot; xparam)
    98  *     
    99  *                     )
   100  *     
   101  *     
   102  *     
   103  *          dtstval    = date-time / date
   104  *          ;Value MUST match value type
   105  * </pre>
   106  * 
   107  * @author Ben Fortuna
   108  */
   109 public class DtStart extends DateProperty {
   111     private static final long serialVersionUID = -5707097476081111815L;
   113     /**
   114      * Default constructor. The time value is initialised to the time of instantiation.
   115      */
   116     public DtStart() {
   117         super(DTSTART, PropertyFactoryImpl.getInstance());
   118     }
   120     /**
   121      * Creates a new DTSTART property initialised with the specified timezone.
   122      * @param timezone initial timezone
   123      */
   124     public DtStart(TimeZone timezone) {
   125         super(DTSTART, timezone, PropertyFactoryImpl.getInstance());
   126     }
   128     /**
   129      * @param aValue a value string for this component
   130      * @throws ParseException where the specified value string is not a valid date-time/date representation
   131      */
   132     public DtStart(final String aValue) throws ParseException {
   133         super(DTSTART, PropertyFactoryImpl.getInstance());
   134         setValue(aValue);
   135     }
   137     /**
   138      * Creates a new DTSTART property initialised with the specified timezone and value.
   139      * @param value a string representation of a DTSTART value
   140      * @param timezone initial timezone
   141      * @throws ParseException where the specified value is not a valid string
   142      * representation
   143      */
   144     public DtStart(String value, TimeZone timezone) throws ParseException {
   145         super(DTSTART, timezone, PropertyFactoryImpl.getInstance());
   146         setValue(value);
   147     }
   149     /**
   150      * @param aList a list of parameters for this component
   151      * @param aValue a value string for this component
   152      * @throws ParseException where the specified value string is not a valid date-time/date representation
   153      */
   154     public DtStart(final ParameterList aList, final String aValue)
   155             throws ParseException {
   156         super(DTSTART, aList, PropertyFactoryImpl.getInstance());
   157         setValue(aValue);
   158     }
   160     /**
   161      * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   162      * @param aDate a date
   163      */
   164     public DtStart(final Date aDate) {
   165         super(DTSTART, PropertyFactoryImpl.getInstance());
   166         setDate(aDate);
   167     }
   169     /**
   170      * Constructs a new DtStart with the specified time.
   171      * @param time the time of the DtStart
   172      * @param utc specifies whether time is UTC
   173      */
   174     public DtStart(final Date time, final boolean utc) {
   175         super(DTSTART, PropertyFactoryImpl.getInstance());
   176         setDate(time);
   177         setUtc(utc);
   178     }
   180     /**
   181      * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   182      * @param aList a list of parameters for this component
   183      * @param aDate a date
   184      */
   185     public DtStart(final ParameterList aList, final Date aDate) {
   186         super(DTSTART, aList, PropertyFactoryImpl.getInstance());
   187         setDate(aDate);
   188     }
   190     /**
   191      * {@inheritDoc}
   192      */
   193     public final void validate() throws ValidationException {
   194         super.validate();
   196         /*
   197          * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) /
   198          * (";" tzidparam) /
   199          */
   201         /*
   202          * ; the following is optional, ; and MAY occur more than once (";" xparam)
   203          */
   204     }
   205 }

mercurial