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

changeset 0
fb9019fb1bf7
equal deleted inserted replaced
-1:000000000000 0:faf4fcd86c32
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 net.fortuna.ical4j.model.Escapable;
35 import net.fortuna.ical4j.model.Parameter;
36 import net.fortuna.ical4j.model.ParameterList;
37 import net.fortuna.ical4j.model.Property;
38 import net.fortuna.ical4j.model.PropertyFactoryImpl;
39 import net.fortuna.ical4j.model.ValidationException;
40 import net.fortuna.ical4j.util.ParameterValidator;
41
42 /**
43 * $Id$
44 *
45 * Created: [Apr 6, 2004]
46 *
47 * Defines a LOCATION iCalendar component property.
48 *
49 * <pre>
50 * 4.8.1.7 Location
51 *
52 * Property Name: LOCATION
53 *
54 * Purpose: The property defines the intended venue for the activity
55 * defined by a calendar component.
56 *
57 * Value Type: TEXT
58 *
59 * Property Parameters: Non-standard, alternate text representation and
60 * language property parameters can be specified on this property.
61 *
62 * Conformance: This property can be specified in &quot;VEVENT&quot; or &quot;VTODO&quot;
63 * calendar component.
64 *
65 * Description: Specific venues such as conference or meeting rooms may
66 * be explicitly specified using this property. An alternate
67 * representation may be specified that is a URI that points to
68 * directory information with more structured specification of the
69 * location. For example, the alternate representation may specify
70 * either an LDAP URI pointing to an LDAP server entry or a CID URI
71 * pointing to a MIME body part containing a vCard [RFC 2426] for the
72 * location.
73 *
74 * Format Definition: The property is defined by the following notation:
75 *
76 * location = &quot;LOCATION locparam &quot;:&quot; text CRLF
77 *
78 * locparam = *(
79 *
80 * ; the following are optional,
81 * ; but MUST NOT occur more than once
82 *
83 * (&quot;;&quot; altrepparam) / (&quot;;&quot; languageparam) /
84 *
85 * ; the following is optional,
86 * ; and MAY occur more than once
87 *
88 * (&quot;;&quot; xparam)
89 *
90 * )
91 *
92 * Example: The following are some examples of this property:
93 *
94 * LOCATION:Conference Room - F123, Bldg. 002
95 *
96 * LOCATION;ALTREP=&quot;http://xyzcorp.com/conf-rooms/f123.vcf&quot;:
97 * Conference Room - F123, Bldg. 002
98 * </pre>
99 *
100 * @author Ben Fortuna
101 */
102 public class Location extends Property implements Escapable {
103
104 private static final long serialVersionUID = 8651881536125682401L;
105
106 private String value;
107
108 /**
109 * Default constructor.
110 */
111 public Location() {
112 super(LOCATION, PropertyFactoryImpl.getInstance());
113 }
114
115 /**
116 * @param aValue a value string for this component
117 */
118 public Location(final String aValue) {
119 super(LOCATION, PropertyFactoryImpl.getInstance());
120 setValue(aValue);
121 }
122
123 /**
124 * @param aList a list of parameters for this component
125 * @param aValue a value string for this component
126 */
127 public Location(final ParameterList aList, final String aValue) {
128 super(LOCATION, aList, PropertyFactoryImpl.getInstance());
129 setValue(aValue);
130 }
131
132 /**
133 * {@inheritDoc}
134 */
135 public final void validate() throws ValidationException {
136
137 /*
138 * ; the following are optional, ; but MUST NOT occur more than once (";" altrepparam) / (";" languageparam) /
139 */
140 ParameterValidator.getInstance().assertOneOrLess(Parameter.ALTREP,
141 getParameters());
142 ParameterValidator.getInstance().assertOneOrLess(Parameter.LANGUAGE,
143 getParameters());
144 ParameterValidator.getInstance().assertOneOrLess(Parameter.VVENUE,
145 getParameters());
146
147 /*
148 * ; the following is optional, ; and MAY occur more than once (";" xparam)
149 */
150 }
151
152 /**
153 * {@inheritDoc}
154 */
155 public final void setValue(final String aValue) {
156 this.value = aValue;
157 }
158
159 /**
160 * {@inheritDoc}
161 */
162 public final String getValue() {
163 return value;
164 }
165 }

mercurial