src/net/fortuna/ical4j/util/Constants.java

changeset 0
fb9019fb1bf7
equal deleted inserted replaced
-1:000000000000 0:8fa42cfb06c8
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.util;
33
34 import net.fortuna.ical4j.model.Property;
35 import net.fortuna.ical4j.model.property.Action;
36 import net.fortuna.ical4j.model.property.CalScale;
37 import net.fortuna.ical4j.model.property.Clazz;
38 import net.fortuna.ical4j.model.property.Method;
39 import net.fortuna.ical4j.model.property.Priority;
40 import net.fortuna.ical4j.model.property.Status;
41 import net.fortuna.ical4j.model.property.Transp;
42 import net.fortuna.ical4j.model.property.Version;
43
44 /**
45 * $Id$
46 *
47 * Created on 5/07/2005
48 *
49 * Provides some convenience methods for working with constant
50 * parameters and properties.
51 * @author Ben Fortuna
52 */
53 public final class Constants {
54
55 /**
56 * Constructor made private to enforce static nature.
57 */
58 private Constants() {
59 }
60
61 /**
62 * Returns a constant equivalent to the specified property
63 * if one is applicable. Otherwise will return the specified
64 * property.
65 * @param property a property instance
66 * @return an equivalent constant property, or the specified property if no equivalent
67 * constant exists
68 */
69 public static Property forProperty(final Property property) {
70 Property retVal = property;
71 if (Action.AUDIO.equals(property)) {
72 retVal = Action.AUDIO;
73 }
74 else if (Action.DISPLAY.equals(property)) {
75 retVal = Action.DISPLAY;
76 }
77 else if (Action.EMAIL.equals(property)) {
78 retVal = Action.EMAIL;
79 }
80 else if (Action.PROCEDURE.equals(property)) {
81 retVal = Action.PROCEDURE;
82 }
83 else if (CalScale.GREGORIAN.equals(property)) {
84 retVal = CalScale.GREGORIAN;
85 }
86 else if (Clazz.CONFIDENTIAL.equals(property)) {
87 retVal = Clazz.CONFIDENTIAL;
88 }
89 else if (Clazz.PRIVATE.equals(property)) {
90 retVal = Clazz.PRIVATE;
91 }
92 else if (Clazz.PUBLIC.equals(property)) {
93 retVal = Clazz.PUBLIC;
94 }
95 else if (Method.ADD.equals(property)) {
96 retVal = Method.ADD;
97 }
98 else if (Method.CANCEL.equals(property)) {
99 retVal = Method.CANCEL;
100 }
101 else if (Method.COUNTER.equals(property)) {
102 retVal = Method.COUNTER;
103 }
104 else if (Method.DECLINE_COUNTER.equals(property)) {
105 retVal = Method.DECLINE_COUNTER;
106 }
107 else if (Method.PUBLISH.equals(property)) {
108 retVal = Method.PUBLISH;
109 }
110 else if (Method.REFRESH.equals(property)) {
111 retVal = Method.REFRESH;
112 }
113 else if (Method.REPLY.equals(property)) {
114 retVal = Method.REPLY;
115 }
116 else if (Method.REQUEST.equals(property)) {
117 retVal = Method.REQUEST;
118 }
119 else if (Priority.HIGH.equals(property)) {
120 retVal = Priority.HIGH;
121 }
122 else if (Priority.LOW.equals(property)) {
123 retVal = Priority.LOW;
124 }
125 else if (Priority.MEDIUM.equals(property)) {
126 retVal = Priority.MEDIUM;
127 }
128 else if (Priority.UNDEFINED.equals(property)) {
129 retVal = Priority.UNDEFINED;
130 }
131 else if (Status.VEVENT_CANCELLED.equals(property)) {
132 retVal = Status.VEVENT_CANCELLED;
133 }
134 else if (Status.VEVENT_CONFIRMED.equals(property)) {
135 retVal = Status.VEVENT_CONFIRMED;
136 }
137 else if (Status.VEVENT_TENTATIVE.equals(property)) {
138 retVal = Status.VEVENT_TENTATIVE;
139 }
140 else if (Status.VJOURNAL_CANCELLED.equals(property)) {
141 retVal = Status.VJOURNAL_CANCELLED;
142 }
143 else if (Status.VJOURNAL_DRAFT.equals(property)) {
144 retVal = Status.VJOURNAL_DRAFT;
145 }
146 else if (Status.VJOURNAL_FINAL.equals(property)) {
147 retVal = Status.VJOURNAL_FINAL;
148 }
149 else if (Status.VTODO_CANCELLED.equals(property)) {
150 retVal = Status.VTODO_CANCELLED;
151 }
152 else if (Status.VTODO_COMPLETED.equals(property)) {
153 retVal = Status.VTODO_COMPLETED;
154 }
155 else if (Status.VTODO_IN_PROCESS.equals(property)) {
156 retVal = Status.VTODO_IN_PROCESS;
157 }
158 else if (Status.VTODO_NEEDS_ACTION.equals(property)) {
159 retVal = Status.VTODO_NEEDS_ACTION;
160 }
161 else if (Transp.OPAQUE.equals(property)) {
162 retVal = Transp.OPAQUE;
163 }
164 else if (Transp.TRANSPARENT.equals(property)) {
165 retVal = Transp.TRANSPARENT;
166 }
167 else if (Version.VERSION_2_0.equals(property)) {
168 retVal = Version.VERSION_2_0;
169 }
170 return retVal;
171 }
172 }

mercurial