1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package net.fortuna.ical4j.model.property;
35
36 import java.util.StringTokenizer;
37
38 import net.fortuna.ical4j.model.Parameter;
39 import net.fortuna.ical4j.model.ParameterList;
40 import net.fortuna.ical4j.model.Property;
41 import net.fortuna.ical4j.model.ValidationException;
42 import net.fortuna.ical4j.util.ParameterValidator;
43
44 /***
45 * Defines a REQUEST-STATUS iCalendar component property.
46 *
47 * @author benf
48 */
49 public class RequestStatus extends Property {
50
51 private static final String PRELIM_SUCCESS = "1";
52
53 private static final String SUCCESS = "2";
54
55 private static final String CLIENT_ERROR = "3";
56
57 private static final String SCHEDULING_ERROR = "4";
58
59 private String statusCode;
60
61 private String description;
62
63 private String exData;
64
65 /***
66 * @param aList
67 * a list of parameters for this component
68 * @param aValue
69 * a value string for this component
70 */
71 public RequestStatus(final ParameterList aList, final String aValue) {
72 super(REQUEST_STATUS, aList);
73
74 StringTokenizer t = new StringTokenizer(aValue, ";");
75
76 if (t.hasMoreTokens()) {
77 statusCode = t.nextToken();
78 }
79
80 if (t.hasMoreTokens()) {
81 description = t.nextToken();
82 }
83
84 if (t.hasMoreTokens()) {
85 exData = t.nextToken();
86 }
87 }
88
89 /***
90 * @param aList
91 * a list of parameters for this component
92 * @param aStatusCode
93 * a string representation of a status code
94 * @param aDescription
95 * a description
96 * @param data
97 * a string representation of extension data
98 */
99 public RequestStatus(final ParameterList aList, final String aStatusCode,
100 final String aDescription, final String data) {
101 super(REQUEST_STATUS, aList);
102
103 statusCode = aStatusCode;
104 description = aDescription;
105 exData = data;
106 }
107
108 /***
109 * @see net.fortuna.ical4j.model.Property#validate()
110 */
111 public final void validate() throws ValidationException {
112
113
114
115
116
117
118 ParameterValidator.getInstance().validateOneOrLess(Parameter.LANGUAGE,
119 getParameters());
120
121
122
123
124
125
126 }
127
128 /***
129 * @return Returns the description.
130 */
131 public final String getDescription() {
132 return description;
133 }
134
135 /***
136 * @return Returns the exData.
137 */
138 public final String getExData() {
139 return exData;
140 }
141
142 /***
143 * @return Returns the statusCode.
144 */
145 public final String getStatusCode() {
146 return statusCode;
147 }
148
149
150
151
152
153
154 public String getValue() {
155 StringBuffer b = new StringBuffer();
156
157 if ((getStatusCode() != null)) {
158 b.append(getStatusCode());
159 b.append(';');
160 }
161
162 if ((getDescription() != null)) {
163 b.append(getDescription());
164 b.append(';');
165 }
166
167 if ((getExData() != null)) {
168 b.append(getExData());
169 }
170
171 return b.toString();
172 }
173 }