1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/net/fortuna/ical4j/model/property/DtEnd.java Tue Feb 10 18:12:00 2015 +0100 1.3 @@ -0,0 +1,208 @@ 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 DTEND iCalendar component property. 1.51 + * 1.52 + * <pre> 1.53 + * 4.8.2.2 Date/Time End 1.54 + * 1.55 + * Property Name: DTEND 1.56 + * 1.57 + * Purpose: This property specifies the date and time that a calendar 1.58 + * component ends. 1.59 + * 1.60 + * Value Type: The default value type is DATE-TIME. The value type can 1.61 + * 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 "VEVENT" or 1.67 + * "VFREEBUSY" calendar components. 1.68 + * 1.69 + * Description: Within the "VEVENT" calendar component, this property 1.70 + * defines the date and time by which the event ends. The value MUST be 1.71 + * later in time than the value of the "DTSTART" property. 1.72 + * 1.73 + * Within the "VFREEBUSY" calendar component, this property defines the 1.74 + * end date and time for the free or busy time information. The time 1.75 + * MUST be specified in the UTC time format. The value MUST be later in 1.76 + * time than the value of the "DTSTART" property. 1.77 + * 1.78 + * Format Definition: The property is defined by the following notation: 1.79 + * 1.80 + * dtend = "DTEND" dtendparam":" dtendval CRLF 1.81 + * 1.82 + * dtendparam = *( 1.83 + * 1.84 + * ; the following are optional, 1.85 + * ; but MUST NOT occur more than once 1.86 + * 1.87 + * (";" "VALUE" "=" ("DATE-TIME" / "DATE")) / 1.88 + * (";" tzidparam) / 1.89 + * 1.90 + * ; the following is optional, 1.91 + * ; and MAY occur more than once 1.92 + * 1.93 + * (";" xparam) 1.94 + * 1.95 + * ) 1.96 + * 1.97 + * 1.98 + * 1.99 + * dtendval = date-time / date 1.100 + * ;Value MUST match value type 1.101 + * </pre> 1.102 + * 1.103 + * Examples: 1.104 + * 1.105 + * <pre> 1.106 + * // construct an end date from a start date and a duration.. 1.107 + * DtStart start = ... 1.108 + * Dur oneWeek = new Dur("1W"); 1.109 + * DtEnd end = new DtEnd(oneWeek.getTime(start.getDate()); 1.110 + * </pre> 1.111 + * 1.112 + * @author Ben Fortuna 1.113 + */ 1.114 +public class DtEnd extends DateProperty { 1.115 + 1.116 + private static final long serialVersionUID = 8107416684717228297L; 1.117 + 1.118 + /** 1.119 + * Default constructor. The time value is initialised to the time of instantiation. 1.120 + */ 1.121 + public DtEnd() { 1.122 + super(DTEND, PropertyFactoryImpl.getInstance()); 1.123 + } 1.124 + 1.125 + /** 1.126 + * Creates a new DTEND property initialised with the specified timezone. 1.127 + * @param timezone initial timezone 1.128 + */ 1.129 + public DtEnd(TimeZone timezone) { 1.130 + super(DTEND, timezone, PropertyFactoryImpl.getInstance()); 1.131 + } 1.132 + 1.133 + /** 1.134 + * Creates a new instance initialised with the parsed value. 1.135 + * @param value the DTEND value string to parse 1.136 + * @throws ParseException where the specified string is not a valid DTEND value representation 1.137 + */ 1.138 + public DtEnd(final String value) throws ParseException { 1.139 + super(DTEND, PropertyFactoryImpl.getInstance()); 1.140 + setValue(value); 1.141 + } 1.142 + 1.143 + /** 1.144 + * Creates a new DTEND property initialised with the specified timezone and value. 1.145 + * @param value a string representation of a DTEND value 1.146 + * @param timezone initial timezone 1.147 + * @throws ParseException where the specified value is not a valid string 1.148 + * representation 1.149 + */ 1.150 + public DtEnd(String value, TimeZone timezone) throws ParseException { 1.151 + super(DTEND, timezone, PropertyFactoryImpl.getInstance()); 1.152 + setValue(value); 1.153 + } 1.154 + 1.155 + /** 1.156 + * @param aList a list of parameters for this component 1.157 + * @param aValue a value string for this component 1.158 + * @throws ParseException when the specified string is not a valid date/date-time representation 1.159 + */ 1.160 + public DtEnd(final ParameterList aList, final String aValue) 1.161 + throws ParseException { 1.162 + super(DTEND, aList, PropertyFactoryImpl.getInstance()); 1.163 + setValue(aValue); 1.164 + } 1.165 + 1.166 + /** 1.167 + * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter. 1.168 + * @param aDate a date 1.169 + */ 1.170 + public DtEnd(final Date aDate) { 1.171 + super(DTEND, PropertyFactoryImpl.getInstance()); 1.172 + setDate(aDate); 1.173 + } 1.174 + 1.175 + /** 1.176 + * Constructs a new DtEnd with the specified time. 1.177 + * @param time the time of the DtEnd 1.178 + * @param utc specifies whether time is UTC 1.179 + */ 1.180 + public DtEnd(final Date time, final boolean utc) { 1.181 + super(DTEND, PropertyFactoryImpl.getInstance()); 1.182 + setDate(time); 1.183 + setUtc(utc); 1.184 + } 1.185 + 1.186 + /** 1.187 + * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter. 1.188 + * @param aList a list of parameters for this component 1.189 + * @param aDate a date 1.190 + */ 1.191 + public DtEnd(final ParameterList aList, final Date aDate) { 1.192 + super(DTEND, aList, PropertyFactoryImpl.getInstance()); 1.193 + setDate(aDate); 1.194 + } 1.195 + 1.196 + /** 1.197 + * {@inheritDoc} 1.198 + */ 1.199 + public final void validate() throws ValidationException { 1.200 + super.validate(); 1.201 + 1.202 + /* 1.203 + * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) / 1.204 + * (";" tzidparam) / 1.205 + */ 1.206 + 1.207 + /* 1.208 + * ; the following is optional, ; and MAY occur more than once (";" xparam) 1.209 + */ 1.210 + } 1.211 +}