|
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.component; |
|
33 |
|
34 import net.fortuna.ical4j.model.Property; |
|
35 import net.fortuna.ical4j.model.PropertyList; |
|
36 import net.fortuna.ical4j.model.ValidationException; |
|
37 import net.fortuna.ical4j.model.Validator; |
|
38 import net.fortuna.ical4j.model.property.Method; |
|
39 import net.fortuna.ical4j.util.PropertyValidator; |
|
40 import net.fortuna.ical4j.util.Strings; |
|
41 |
|
42 /** |
|
43 * $Id $ [Apr 5, 2004] |
|
44 * |
|
45 * Defines an iCalendar VVENUE component. |
|
46 * |
|
47 * <pre> |
|
48 * 4. Venue Component |
|
49 * |
|
50 * Component Name: "VVENUE" |
|
51 * |
|
52 * Purpose: Provide a grouping of component properties that describe an |
|
53 * event venue. |
|
54 * |
|
55 * Format Definition: A "VVENUE" calendar component is defined by the |
|
56 * following notation: |
|
57 * venuec = "BEGIN" ":" "VVENUE" CRLF |
|
58 * venueprop |
|
59 * "END" ":" "VVENUE" CRLF |
|
60 * |
|
61 * venueprop = *( |
|
62 * |
|
63 * ; the following are all REQUIRED, |
|
64 * ; but MUST NOT occur more than once |
|
65 * |
|
66 * uid |
|
67 * |
|
68 * ; the following are optional, |
|
69 * ; but MUST NOT occur more than once |
|
70 * |
|
71 * name / description / street-address / extended-address / |
|
72 * locality / region / country / postal-code / tzid / geo / |
|
73 * location-type / categories |
|
74 * |
|
75 * ; the following are optional, |
|
76 * ; and MAY occur more than once |
|
77 * |
|
78 * tel / url |
|
79 * ) |
|
80 * |
|
81 * Description: A "VVENUE" calendar component is a grouping of component |
|
82 * properties that represent a venue where an event occurs. This |
|
83 * extends the "LOCATION" property of "VEVENT" and "TODO" components, |
|
84 * providing the ability to specify detailed information about the event |
|
85 * venue. |
|
86 * |
|
87 * </pre> |
|
88 * |
|
89 * @author Ben Fortuna |
|
90 * @author Mike Douglass |
|
91 */ |
|
92 public class VVenue extends CalendarComponent { |
|
93 |
|
94 private static final long serialVersionUID = 4502423035501438515L; |
|
95 |
|
96 /** |
|
97 * Default constructor. |
|
98 */ |
|
99 public VVenue() { |
|
100 super(VVENUE); |
|
101 } |
|
102 |
|
103 /** |
|
104 * Constructs a new instance containing the specified properties. |
|
105 * @param properties a list of properties |
|
106 */ |
|
107 public VVenue(final PropertyList properties) { |
|
108 super(VVENUE, properties); |
|
109 } |
|
110 |
|
111 /** |
|
112 * {@inheritDoc} |
|
113 */ |
|
114 public final String toString() { |
|
115 final StringBuffer b = new StringBuffer(); |
|
116 b.append(BEGIN); |
|
117 b.append(':'); |
|
118 b.append(getName()); |
|
119 b.append(Strings.LINE_SEPARATOR); |
|
120 b.append(getProperties()); |
|
121 b.append(END); |
|
122 b.append(':'); |
|
123 b.append(getName()); |
|
124 b.append(Strings.LINE_SEPARATOR); |
|
125 return b.toString(); |
|
126 } |
|
127 |
|
128 /** |
|
129 * {@inheritDoc} |
|
130 */ |
|
131 public final void validate(final boolean recurse) |
|
132 throws ValidationException { |
|
133 |
|
134 /* |
|
135 * ; 'uiid' is required, but MUST NOT occur more ; than once uiid / |
|
136 */ |
|
137 PropertyValidator.getInstance().assertOne(Property.UID, |
|
138 getProperties()); |
|
139 |
|
140 /* |
|
141 * ; the following are optional, |
|
142 * ; but MUST NOT occur more than once |
|
143 * |
|
144 * name / description / street-address / extended-address / |
|
145 * locality / region / country / postal-code / tzid / geo / |
|
146 * location-type / categories / |
|
147 * dtstamp / created / last-modified |
|
148 */ |
|
149 PropertyValidator.getInstance().assertOneOrLess(Property.NAME, |
|
150 getProperties()); |
|
151 PropertyValidator.getInstance().assertOneOrLess(Property.DESCRIPTION, |
|
152 getProperties()); |
|
153 PropertyValidator.getInstance().assertOneOrLess(Property.STREET_ADDRESS, |
|
154 getProperties()); |
|
155 PropertyValidator.getInstance().assertOneOrLess(Property.EXTENDED_ADDRESS, |
|
156 getProperties()); |
|
157 PropertyValidator.getInstance().assertOneOrLess(Property.LOCALITY, |
|
158 getProperties()); |
|
159 PropertyValidator.getInstance().assertOneOrLess(Property.REGION, |
|
160 getProperties()); |
|
161 PropertyValidator.getInstance().assertOneOrLess(Property.COUNTRY, |
|
162 getProperties()); |
|
163 PropertyValidator.getInstance().assertOneOrLess(Property.POSTALCODE, |
|
164 getProperties()); |
|
165 PropertyValidator.getInstance().assertOneOrLess(Property.TZID, |
|
166 getProperties()); |
|
167 PropertyValidator.getInstance().assertOneOrLess(Property.GEO, |
|
168 getProperties()); |
|
169 PropertyValidator.getInstance().assertOneOrLess(Property.LOCATION_TYPE, |
|
170 getProperties()); |
|
171 PropertyValidator.getInstance().assertOneOrLess(Property.CATEGORIES, |
|
172 getProperties()); |
|
173 PropertyValidator.getInstance().assertOneOrLess(Property.DTSTAMP, |
|
174 getProperties()); |
|
175 PropertyValidator.getInstance().assertOneOrLess(Property.CREATED, |
|
176 getProperties()); |
|
177 PropertyValidator.getInstance().assertOneOrLess(Property.LAST_MODIFIED, |
|
178 getProperties()); |
|
179 |
|
180 /* |
|
181 * ; the following is optional, ; and MAY occur more than once tel / url / x-prop |
|
182 */ |
|
183 |
|
184 if (recurse) { |
|
185 validateProperties(); |
|
186 } |
|
187 } |
|
188 |
|
189 /** |
|
190 * {@inheritDoc} |
|
191 */ |
|
192 protected Validator getValidator(Method method) { |
|
193 // No method validation required.. |
|
194 return EMPTY_VALIDATOR; |
|
195 } |
|
196 } |