Tue, 10 Feb 2015 19:58:00 +0100
Upgrade the upgraded ical4j component to use org.apache.commons.lang3.
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;
34 import net.fortuna.ical4j.model.ParameterList;
35 import net.fortuna.ical4j.model.Property;
36 import net.fortuna.ical4j.model.PropertyFactoryImpl;
37 import net.fortuna.ical4j.model.ValidationException;
39 /**
40 * $Id$
41 *
42 * Created: [Apr 6, 2004]
43 *
44 * Defines a PRIORITY iCalendar component property.
45 *
46 * <pre>
47 * 4.8.1.9 Priority
48 *
49 * Property Name: PRIORITY
50 *
51 * Purpose: The property defines the relative priority for a calendar
52 * component.
53 *
54 * Value Type: INTEGER
55 *
56 * Property Parameters: Non-standard property parameters can be
57 * specified on this property.
58 *
59 * Conformance: The property can be specified in a "VEVENT" or "VTODO"
60 * calendar component.
61 *
62 * Description: The priority is specified as an integer in the range
63 * zero to nine. A value of zero (US-ASCII decimal 48) specifies an
64 * undefined priority. A value of one (US-ASCII decimal 49) is the
65 * highest priority. A value of two (US-ASCII decimal 50) is the second
66 * highest priority. Subsequent numbers specify a decreasing ordinal
67 * priority. A value of nine (US-ASCII decimal 58) is the lowest
68 * priority.
69 *
70 * A CUA with a three-level priority scheme of "HIGH", "MEDIUM" and
71 * "LOW" is mapped into this property such that a property value in the
72 * range of one (US-ASCII decimal 49) to four (US-ASCII decimal 52)
73 * specifies "HIGH" priority. A value of five (US-ASCII decimal 53) is
74 * the normal or "MEDIUM" priority. A value in the range of six (US-
75 * ASCII decimal 54) to nine (US-ASCII decimal 58) is "LOW" priority.
76 *
77 * A CUA with a priority schema of "A1", "A2", "A3",
78 * "B1", "B2", ...,
79 * "C3" is mapped into this property such that a property value of one
80 * (US-ASCII decimal 49) specifies "A1", a property value of two (US-
81 * ASCII decimal 50) specifies "A2", a property value of three (US-ASCII
82 * decimal 51) specifies "A3", and so forth up to a property value of 9
83 * (US-ASCII decimal 58) specifies "C3".
84 *
85 * Other integer values are reserved for future use.
86 *
87 * Within a "VEVENT" calendar component, this property specifies a
88 * priority for the event. This property may be useful when more than
89 * one event is scheduled for a given time period.
90 *
91 * Within a "VTODO" calendar component, this property specified a
92 * priority for the to-do. This property is useful in prioritizing
93 * multiple action items for a given time period.
94 *
95 * Format Definition: The property is specified by the following
96 * notation:
97 *
98 * priority = "PRIORITY" prioparam ":" privalue CRLF
99 * ;Default is zero
100 *
101 * prioparam = *(";" xparam)
102 *
103 * privalue = integer ;Must be in the range [0..9]
104 * ; All other values are reserved for future use
105 *
106 * The following is an example of a property with the highest priority:
107 *
108 * PRIORITY:1
109 *
110 * The following is an example of a property with a next highest
111 * priority:
112 *
113 * PRIORITY:2
114 *
115 * Example: The following is an example of a property with no priority.
116 * This is equivalent to not specifying the "PRIORITY" property:
117 *
118 * PRIORITY:0
119 * </pre>
120 *
121 * @author Ben Fortuna
122 */
123 public class Priority extends Property {
125 private static final long serialVersionUID = -5654367843953827397L;
127 /**
128 * Undefined priority.
129 */
130 public static final Priority UNDEFINED = new ImmutablePriority(0);
132 /**
133 * High priority.
134 */
135 public static final Priority HIGH = new ImmutablePriority(1);
137 /**
138 * Medium priority.
139 */
140 public static final Priority MEDIUM = new ImmutablePriority(5);
142 /**
143 * Low priority.
144 */
145 public static final Priority LOW = new ImmutablePriority(9);
147 /**
148 * @author Ben Fortuna An immutable instance of Priority.
149 */
150 private static final class ImmutablePriority extends Priority {
152 private static final long serialVersionUID = 5884973714694108418L;
154 private ImmutablePriority(final int level) {
155 super(new ParameterList(true), level);
156 }
158 public void setValue(final String aValue) {
159 throw new UnsupportedOperationException(
160 "Cannot modify constant instances");
161 }
163 public void setLevel(final int level) {
164 throw new UnsupportedOperationException(
165 "Cannot modify constant instances");
166 }
167 }
169 private int level;
171 /**
172 * Default constructor.
173 */
174 public Priority() {
175 super(PRIORITY, PropertyFactoryImpl.getInstance());
176 level = UNDEFINED.getLevel();
177 }
179 /**
180 * @param aList a list of parameters for this component
181 * @param aValue a value string for this component
182 */
183 public Priority(final ParameterList aList, final String aValue) {
184 super(PRIORITY, aList, PropertyFactoryImpl.getInstance());
185 level = Integer.parseInt(aValue);
186 }
188 /**
189 * @param aLevel an int representation of a priority level
190 */
191 public Priority(final int aLevel) {
192 super(PRIORITY, PropertyFactoryImpl.getInstance());
193 level = aLevel;
194 }
196 /**
197 * @param aList a list of parameters for this component
198 * @param aLevel an int representation of a priority level
199 */
200 public Priority(final ParameterList aList, final int aLevel) {
201 super(PRIORITY, aList, PropertyFactoryImpl.getInstance());
202 level = aLevel;
203 }
205 /**
206 * @return Returns the level.
207 */
208 public final int getLevel() {
209 return level;
210 }
212 /**
213 * {@inheritDoc}
214 */
215 public void setValue(final String aValue) {
216 level = Integer.parseInt(aValue);
217 }
219 /**
220 * {@inheritDoc}
221 */
222 public final String getValue() {
223 return String.valueOf(getLevel());
224 }
226 /**
227 * @param level The level to set.
228 */
229 public void setLevel(final int level) {
230 this.level = level;
231 }
233 /**
234 * {@inheritDoc}
235 */
236 public final void validate() throws ValidationException {
237 // TODO: Auto-generated method stub
238 }
239 }