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

changeset 0
fb9019fb1bf7
equal deleted inserted replaced
-1:000000000000 0:0e7c9321dbc5
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;
33
34 import java.text.ParseException;
35
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;
41
42 /**
43 * $Id$
44 *
45 * Created: [Apr 6, 2004]
46 *
47 * Defines a DTEND iCalendar component property.
48 *
49 * <pre>
50 * 4.8.2.2 Date/Time End
51 *
52 * Property Name: DTEND
53 *
54 * Purpose: This property specifies the date and time that a calendar
55 * component ends.
56 *
57 * Value Type: The default value type is DATE-TIME. The value type can
58 * 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 &quot;VEVENT&quot; or
64 * &quot;VFREEBUSY&quot; calendar components.
65 *
66 * Description: Within the &quot;VEVENT&quot; calendar component, this property
67 * defines the date and time by which the event ends. The value MUST be
68 * later in time than the value of the &quot;DTSTART&quot; property.
69 *
70 * Within the &quot;VFREEBUSY&quot; calendar component, this property defines the
71 * end date and time for the free or busy time information. The time
72 * MUST be specified in the UTC time format. The value MUST be later in
73 * time than the value of the &quot;DTSTART&quot; property.
74 *
75 * Format Definition: The property is defined by the following notation:
76 *
77 * dtend = &quot;DTEND&quot; dtendparam&quot;:&quot; dtendval CRLF
78 *
79 * dtendparam = *(
80 *
81 * ; the following are optional,
82 * ; but MUST NOT occur more than once
83 *
84 * (&quot;;&quot; &quot;VALUE&quot; &quot;=&quot; (&quot;DATE-TIME&quot; / &quot;DATE&quot;)) /
85 * (&quot;;&quot; tzidparam) /
86 *
87 * ; the following is optional,
88 * ; and MAY occur more than once
89 *
90 * (&quot;;&quot; xparam)
91 *
92 * )
93 *
94 *
95 *
96 * dtendval = date-time / date
97 * ;Value MUST match value type
98 * </pre>
99 *
100 * Examples:
101 *
102 * <pre>
103 * // construct an end date from a start date and a duration..
104 * DtStart start = ...
105 * Dur oneWeek = new Dur(&quot;1W&quot;);
106 * DtEnd end = new DtEnd(oneWeek.getTime(start.getDate());
107 * </pre>
108 *
109 * @author Ben Fortuna
110 */
111 public class DtEnd extends DateProperty {
112
113 private static final long serialVersionUID = 8107416684717228297L;
114
115 /**
116 * Default constructor. The time value is initialised to the time of instantiation.
117 */
118 public DtEnd() {
119 super(DTEND, PropertyFactoryImpl.getInstance());
120 }
121
122 /**
123 * Creates a new DTEND property initialised with the specified timezone.
124 * @param timezone initial timezone
125 */
126 public DtEnd(TimeZone timezone) {
127 super(DTEND, timezone, PropertyFactoryImpl.getInstance());
128 }
129
130 /**
131 * Creates a new instance initialised with the parsed value.
132 * @param value the DTEND value string to parse
133 * @throws ParseException where the specified string is not a valid DTEND value representation
134 */
135 public DtEnd(final String value) throws ParseException {
136 super(DTEND, PropertyFactoryImpl.getInstance());
137 setValue(value);
138 }
139
140 /**
141 * Creates a new DTEND property initialised with the specified timezone and value.
142 * @param value a string representation of a DTEND value
143 * @param timezone initial timezone
144 * @throws ParseException where the specified value is not a valid string
145 * representation
146 */
147 public DtEnd(String value, TimeZone timezone) throws ParseException {
148 super(DTEND, timezone, PropertyFactoryImpl.getInstance());
149 setValue(value);
150 }
151
152 /**
153 * @param aList a list of parameters for this component
154 * @param aValue a value string for this component
155 * @throws ParseException when the specified string is not a valid date/date-time representation
156 */
157 public DtEnd(final ParameterList aList, final String aValue)
158 throws ParseException {
159 super(DTEND, aList, PropertyFactoryImpl.getInstance());
160 setValue(aValue);
161 }
162
163 /**
164 * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
165 * @param aDate a date
166 */
167 public DtEnd(final Date aDate) {
168 super(DTEND, PropertyFactoryImpl.getInstance());
169 setDate(aDate);
170 }
171
172 /**
173 * Constructs a new DtEnd with the specified time.
174 * @param time the time of the DtEnd
175 * @param utc specifies whether time is UTC
176 */
177 public DtEnd(final Date time, final boolean utc) {
178 super(DTEND, PropertyFactoryImpl.getInstance());
179 setDate(time);
180 setUtc(utc);
181 }
182
183 /**
184 * Constructor. Date or Date-Time format is determined based on the presence of a VALUE parameter.
185 * @param aList a list of parameters for this component
186 * @param aDate a date
187 */
188 public DtEnd(final ParameterList aList, final Date aDate) {
189 super(DTEND, aList, PropertyFactoryImpl.getInstance());
190 setDate(aDate);
191 }
192
193 /**
194 * {@inheritDoc}
195 */
196 public final void validate() throws ValidationException {
197 super.validate();
198
199 /*
200 * ; the following are optional, ; but MUST NOT occur more than once (";" "VALUE" "=" ("DATE-TIME" / "DATE")) /
201 * (";" tzidparam) /
202 */
203
204 /*
205 * ; the following is optional, ; and MAY occur more than once (";" xparam)
206 */
207 }
208 }

mercurial