src/net/fortuna/ical4j/model/property/Due.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/Due.java	Tue Feb 10 18:12:00 2015 +0100
     1.3 @@ -0,0 +1,184 @@
     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.DateTime;
    1.41 +import net.fortuna.ical4j.model.ParameterList;
    1.42 +import net.fortuna.ical4j.model.PropertyFactoryImpl;
    1.43 +import net.fortuna.ical4j.model.TimeZone;
    1.44 +import net.fortuna.ical4j.model.ValidationException;
    1.45 +
    1.46 +/**
    1.47 + * $Id$
    1.48 + * 
    1.49 + * Created: [Apr 6, 2004]
    1.50 + *
    1.51 + * Defines a DUE iCalendar component property.
    1.52 + * 
    1.53 + * <pre>
    1.54 + *     4.8.2.3 Date/Time Due
    1.55 + *     
    1.56 + *        Property Name: DUE
    1.57 + *     
    1.58 + *        Purpose: This property defines the date and time that a to-do is
    1.59 + *        expected to be completed.
    1.60 + *     
    1.61 + *        Value Type: The default value type is DATE-TIME. The value type can
    1.62 + *        be set to a DATE value type.
    1.63 + *     
    1.64 + *        Property Parameters: Non-standard, value data type, time zone
    1.65 + *        identifier property parameters can be specified on this property.
    1.66 + *     
    1.67 + *        Conformance: The property can be specified once in a &quot;VTODO&quot; calendar
    1.68 + *        component.
    1.69 + *     
    1.70 + *        Description: The value MUST be a date/time equal to or after the
    1.71 + *        DTSTART value, if specified.
    1.72 + *     
    1.73 + *        Format Definition: The property is defined by the following notation:
    1.74 + *     
    1.75 + *          due        = &quot;DUE&quot; dueparam&quot;:&quot; dueval CRLF
    1.76 + *     
    1.77 + *          dueparam   = *(
    1.78 + *                     ; the following are optional,
    1.79 + *                     ; but MUST NOT occur more than once
    1.80 + *     
    1.81 + *                     (&quot;;&quot; &quot;VALUE&quot; &quot;=&quot; (&quot;DATE-TIME&quot; / &quot;DATE&quot;)) /
    1.82 + *                     (&quot;;&quot; tzidparam) /
    1.83 + *     
    1.84 + *                     ; the following is optional,
    1.85 + *                     ; and MAY occur more than once
    1.86 + *     
    1.87 + *                       *(&quot;;&quot; xparam)
    1.88 + *     
    1.89 + *                     )
    1.90 + *     
    1.91 + *     
    1.92 + *     
    1.93 + *          dueval     = date-time / date
    1.94 + *          ;Value MUST match value type
    1.95 + * </pre>
    1.96 + * 
    1.97 + * @author Ben Fortuna
    1.98 + */
    1.99 +public class Due extends DateProperty {
   1.100 +
   1.101 +    private static final long serialVersionUID = -2965312347832730406L;
   1.102 +
   1.103 +    /**
   1.104 +     * Default constructor. The time value is initialised to the time of instantiation.
   1.105 +     */
   1.106 +    public Due() {
   1.107 +        super(DUE, PropertyFactoryImpl.getInstance());
   1.108 +        // defaults to UTC time..
   1.109 +        setDate(new DateTime(true));
   1.110 +    }
   1.111 +
   1.112 +    /**
   1.113 +     * Creates a new DUE property initialised with the specified timezone.
   1.114 +     * @param timezone initial timezone
   1.115 +     */
   1.116 +    public Due(TimeZone timezone) {
   1.117 +        super(DUE, timezone, PropertyFactoryImpl.getInstance());
   1.118 +    }
   1.119 +
   1.120 +    /**
   1.121 +     * Creates a new instance initialised with the parsed value.
   1.122 +     * @param value the DUE value string to parse
   1.123 +     * @throws ParseException where the specified string is not a valid DUE value representation
   1.124 +     */
   1.125 +    public Due(final String value) throws ParseException {
   1.126 +        super(DUE, PropertyFactoryImpl.getInstance());
   1.127 +        setValue(value);
   1.128 +    }
   1.129 +
   1.130 +    /**
   1.131 +     * Creates a new DUE property initialised with the specified timezone and value.
   1.132 +     * @param value a string representation of a DUE value
   1.133 +     * @param timezone initial timezone
   1.134 +     * @throws ParseException where the specified value is not a valid string
   1.135 +     * representation
   1.136 +     */
   1.137 +    public Due(String value, TimeZone timezone) throws ParseException {
   1.138 +        super(DUE, timezone, PropertyFactoryImpl.getInstance());
   1.139 +        setValue(value);
   1.140 +    }
   1.141 +
   1.142 +    /**
   1.143 +     * @param aList a list of parameters for this component
   1.144 +     * @param aValue a value string for this component
   1.145 +     * @throws ParseException when the specified string is not a valid date/date-time representation
   1.146 +     */
   1.147 +    public Due(final ParameterList aList, final String aValue)
   1.148 +            throws ParseException {
   1.149 +        super(DUE, aList, PropertyFactoryImpl.getInstance());
   1.150 +        setValue(aValue);
   1.151 +    }
   1.152 +
   1.153 +    /**
   1.154 +     * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
   1.155 +     * @param aDate a date
   1.156 +     */
   1.157 +    public Due(final Date aDate) {
   1.158 +        super(DUE, PropertyFactoryImpl.getInstance());
   1.159 +        setDate(aDate);
   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 aList a list of parameters for this component
   1.165 +     * @param aDate a date
   1.166 +     */
   1.167 +    public Due(final ParameterList aList, final Date aDate) {
   1.168 +        super(DUE, aList, PropertyFactoryImpl.getInstance());
   1.169 +        setDate(aDate);
   1.170 +    }
   1.171 +
   1.172 +    /**
   1.173 +     * {@inheritDoc}
   1.174 +     */
   1.175 +    public final void validate() throws ValidationException {
   1.176 +        super.validate();
   1.177 +
   1.178 +        /*
   1.179 +         * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) /
   1.180 +         * (";" tzidparam) /
   1.181 +         */
   1.182 +
   1.183 +        /*
   1.184 +         * ; the following is optional, ; and MAY occur more than once (";" xparam)
   1.185 +         */
   1.186 +    }
   1.187 +}

mercurial