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

Tue, 10 Feb 2015 18:12:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 10 Feb 2015 18:12:00 +0100
changeset 0
fb9019fb1bf7
permissions
-rw-r--r--

Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.

     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.DateTime;
    38 import net.fortuna.ical4j.model.ParameterList;
    39 import net.fortuna.ical4j.model.PropertyFactoryImpl;
    40 import net.fortuna.ical4j.model.TimeZone;
    41 import net.fortuna.ical4j.model.ValidationException;
    43 /**
    44  * $Id$
    45  * 
    46  * Created: [Apr 6, 2004]
    47  *
    48  * Defines a DUE iCalendar component property.
    49  * 
    50  * <pre>
    51  *     4.8.2.3 Date/Time Due
    52  *     
    53  *        Property Name: DUE
    54  *     
    55  *        Purpose: This property defines the date and time that a to-do is
    56  *        expected to be completed.
    57  *     
    58  *        Value Type: The default value type is DATE-TIME. The value type can
    59  *        be set to a DATE value type.
    60  *     
    61  *        Property Parameters: Non-standard, value data type, time zone
    62  *        identifier property parameters can be specified on this property.
    63  *     
    64  *        Conformance: The property can be specified once in a &quot;VTODO&quot; calendar
    65  *        component.
    66  *     
    67  *        Description: The value MUST be a date/time equal to or after the
    68  *        DTSTART value, if specified.
    69  *     
    70  *        Format Definition: The property is defined by the following notation:
    71  *     
    72  *          due        = &quot;DUE&quot; dueparam&quot;:&quot; dueval CRLF
    73  *     
    74  *          dueparam   = *(
    75  *                     ; the following are optional,
    76  *                     ; but MUST NOT occur more than once
    77  *     
    78  *                     (&quot;;&quot; &quot;VALUE&quot; &quot;=&quot; (&quot;DATE-TIME&quot; / &quot;DATE&quot;)) /
    79  *                     (&quot;;&quot; tzidparam) /
    80  *     
    81  *                     ; the following is optional,
    82  *                     ; and MAY occur more than once
    83  *     
    84  *                       *(&quot;;&quot; xparam)
    85  *     
    86  *                     )
    87  *     
    88  *     
    89  *     
    90  *          dueval     = date-time / date
    91  *          ;Value MUST match value type
    92  * </pre>
    93  * 
    94  * @author Ben Fortuna
    95  */
    96 public class Due extends DateProperty {
    98     private static final long serialVersionUID = -2965312347832730406L;
   100     /**
   101      * Default constructor. The time value is initialised to the time of instantiation.
   102      */
   103     public Due() {
   104         super(DUE, PropertyFactoryImpl.getInstance());
   105         // defaults to UTC time..
   106         setDate(new DateTime(true));
   107     }
   109     /**
   110      * Creates a new DUE property initialised with the specified timezone.
   111      * @param timezone initial timezone
   112      */
   113     public Due(TimeZone timezone) {
   114         super(DUE, timezone, PropertyFactoryImpl.getInstance());
   115     }
   117     /**
   118      * Creates a new instance initialised with the parsed value.
   119      * @param value the DUE value string to parse
   120      * @throws ParseException where the specified string is not a valid DUE value representation
   121      */
   122     public Due(final String value) throws ParseException {
   123         super(DUE, PropertyFactoryImpl.getInstance());
   124         setValue(value);
   125     }
   127     /**
   128      * Creates a new DUE property initialised with the specified timezone and value.
   129      * @param value a string representation of a DUE value
   130      * @param timezone initial timezone
   131      * @throws ParseException where the specified value is not a valid string
   132      * representation
   133      */
   134     public Due(String value, TimeZone timezone) throws ParseException {
   135         super(DUE, timezone, PropertyFactoryImpl.getInstance());
   136         setValue(value);
   137     }
   139     /**
   140      * @param aList a list of parameters for this component
   141      * @param aValue a value string for this component
   142      * @throws ParseException when the specified string is not a valid date/date-time representation
   143      */
   144     public Due(final ParameterList aList, final String aValue)
   145             throws ParseException {
   146         super(DUE, aList, PropertyFactoryImpl.getInstance());
   147         setValue(aValue);
   148     }
   150     /**
   151      * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   152      * @param aDate a date
   153      */
   154     public Due(final Date aDate) {
   155         super(DUE, PropertyFactoryImpl.getInstance());
   156         setDate(aDate);
   157     }
   159     /**
   160      * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   161      * @param aList a list of parameters for this component
   162      * @param aDate a date
   163      */
   164     public Due(final ParameterList aList, final Date aDate) {
   165         super(DUE, aList, PropertyFactoryImpl.getInstance());
   166         setDate(aDate);
   167     }
   169     /**
   170      * {@inheritDoc}
   171      */
   172     public final void validate() throws ValidationException {
   173         super.validate();
   175         /*
   176          * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) /
   177          * (";" tzidparam) /
   178          */
   180         /*
   181          * ; the following is optional, ; and MAY occur more than once (";" xparam)
   182          */
   183     }
   184 }

mercurial