1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
package org.webmacro; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public class PropertyException extends ContextException |
42 | |
{ |
43 | |
private static final long serialVersionUID = 1L; |
44 | |
|
45 | 58 | private String _message = null; |
46 | |
|
47 | |
public PropertyException (String reason) |
48 | |
{ |
49 | 48 | super(reason); |
50 | 48 | } |
51 | |
|
52 | |
public PropertyException (String reason, Throwable e) |
53 | |
{ |
54 | 10 | super(reason, e); |
55 | 10 | } |
56 | |
|
57 | |
public PropertyException (String reason, Throwable e, String contextLocation) |
58 | |
{ |
59 | 0 | super(reason, e); |
60 | 0 | setContextLocation(contextLocation); |
61 | 0 | } |
62 | |
|
63 | |
public void setMessage (String message) |
64 | |
{ |
65 | 0 | _message = message; |
66 | 0 | } |
67 | |
|
68 | |
public String getMessage () |
69 | |
{ |
70 | 96 | if (_message == null) |
71 | |
{ |
72 | 96 | return super.getMessage(); |
73 | |
} |
74 | |
else |
75 | |
{ |
76 | 0 | String msg = _message; |
77 | 0 | if (getContextLocation() != null && msg != null) |
78 | |
{ |
79 | 0 | msg += " at " + getContextLocation(); |
80 | |
} |
81 | 0 | return msg; |
82 | |
} |
83 | |
} |
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public static class NoSuchVariableException extends PropertyException |
93 | |
{ |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
private static final long serialVersionUID = 1L; |
99 | |
public String variableName; |
100 | |
|
101 | |
public NoSuchVariableException (String variableName) |
102 | |
{ |
103 | 1 | super("No such variable: $" + variableName); |
104 | |
|
105 | 1 | this.variableName = variableName; |
106 | 1 | } |
107 | |
} |
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
public static class NullToStringException extends PropertyException |
116 | |
{ |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
private static final long serialVersionUID = 1L; |
122 | |
public String variableName; |
123 | |
|
124 | |
public NullToStringException (String variableName) |
125 | |
{ |
126 | 2 | super(".toString() returns null: $" + variableName); |
127 | |
|
128 | 2 | this.variableName = variableName; |
129 | 2 | } |
130 | |
} |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public static class NullValueException extends PropertyException |
139 | |
{ |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
private static final long serialVersionUID = 1L; |
145 | |
public String variableName; |
146 | |
|
147 | |
public NullValueException (String variableName) |
148 | |
{ |
149 | 6 | super("Value is null: $" + variableName); |
150 | 6 | this.variableName = variableName; |
151 | 6 | } |
152 | |
} |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public static class NoSuchMethodException extends PropertyException |
160 | |
{ |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
private static final long serialVersionUID = 1L; |
166 | |
public String methodName, className, variableName; |
167 | |
|
168 | |
public NoSuchMethodException (String methodName, |
169 | |
String variableName, |
170 | |
String className) |
171 | |
{ |
172 | 8 | super("No public method " + methodName + " on variable $" |
173 | |
+ variableName + " of class " + className); |
174 | 8 | this.variableName = variableName; |
175 | 8 | this.className = className; |
176 | 8 | this.methodName = methodName; |
177 | 8 | } |
178 | |
} |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
public static class NoSuchMethodWithArgumentsException extends PropertyException |
185 | |
{ |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
private static final long serialVersionUID = 1L; |
191 | |
public String methodName; |
192 | |
public String className; |
193 | |
public String arguments; |
194 | |
|
195 | |
public NoSuchMethodWithArgumentsException (String methodName, |
196 | |
String className, |
197 | |
String arguments) |
198 | |
{ |
199 | 6 | super("No public method " + methodName + "(" + arguments + ")" |
200 | |
+ " in class " + className); |
201 | 6 | this.className = className; |
202 | 6 | this.methodName = methodName; |
203 | 6 | this.arguments = arguments; |
204 | 6 | } |
205 | |
} |
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | |
|
211 | |
public static class NoSuchPropertyException extends PropertyException |
212 | |
{ |
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
private static final long serialVersionUID = 1L; |
218 | |
String _propertyName; |
219 | |
String _className; |
220 | |
String _variableName; |
221 | |
|
222 | |
public NoSuchPropertyException (String propertyName, |
223 | |
String variableName, |
224 | |
String className) |
225 | |
{ |
226 | 7 | super("No public property " + propertyName + " on variable $" |
227 | |
+ variableName + " of class " + className); |
228 | 7 | this._variableName = variableName; |
229 | 7 | this._className = className; |
230 | 7 | this._propertyName = propertyName; |
231 | 7 | } |
232 | |
} |
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
public static class VoidValueException extends PropertyException |
240 | |
{ |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
private static final long serialVersionUID = 1L; |
246 | |
String _variableName; |
247 | |
|
248 | |
|
249 | |
public VoidValueException () |
250 | |
{ |
251 | 3 | super("Attempt to use void value"); |
252 | 3 | } |
253 | |
|
254 | |
public VoidValueException (String variableName) |
255 | |
{ |
256 | 0 | super("Variable $" + variableName + " has a void value "); |
257 | 0 | this._variableName = variableName; |
258 | 0 | } |
259 | |
} |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
public static class InvalidTypeException extends PropertyException |
265 | |
{ |
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
private static final long serialVersionUID = 1L; |
271 | |
|
272 | |
public InvalidTypeException (String variableName, Class clazz) |
273 | |
{ |
274 | 0 | super("$" + variableName + " is not a " + clazz.getName()); |
275 | 0 | } |
276 | |
} |
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
public static class RestrictedPropertyException extends PropertyException |
284 | |
{ |
285 | |
|
286 | |
|
287 | |
|
288 | |
|
289 | |
private static final long serialVersionUID = 1L; |
290 | |
String _propertyName; |
291 | |
String _className; |
292 | |
String _variableName; |
293 | |
|
294 | |
public RestrictedPropertyException (String propertyName, |
295 | |
String variableName, |
296 | |
String className) |
297 | |
{ |
298 | 0 | super("The property " + propertyName + " on variable $" |
299 | |
+ variableName + " of class " + className + " may not be accessed from a template."); |
300 | 0 | this._variableName = variableName; |
301 | 0 | this._className = className; |
302 | 0 | this._propertyName = propertyName; |
303 | 0 | } |
304 | |
} |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
public static class RestrictedMethodException extends PropertyException |
312 | |
{ |
313 | |
|
314 | |
|
315 | |
|
316 | |
|
317 | |
private static final long serialVersionUID = 1L; |
318 | |
String _propertyName; |
319 | |
String _className; |
320 | |
String _variableName; |
321 | |
|
322 | |
public RestrictedMethodException (String propertyName, |
323 | |
String variableName, |
324 | |
String className) |
325 | |
{ |
326 | 0 | super("The method " + propertyName + " on variable $" |
327 | |
+ variableName + " of class " + className + " may not be accessed from a template."); |
328 | 0 | this._variableName = variableName; |
329 | 0 | this._className = className; |
330 | 0 | this._propertyName = propertyName; |
331 | 0 | } |
332 | |
} |
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
public static class UndefinedVariableException extends PropertyException |
339 | |
{ |
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
private static final long serialVersionUID = 1L; |
345 | 10 | private String _msg = "Attempted to dereference an undefined variable."; |
346 | |
|
347 | |
public UndefinedVariableException () |
348 | |
{ |
349 | 10 | super(null); |
350 | 10 | } |
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
public String getMessage () |
357 | |
{ |
358 | 20 | String msg = _msg; |
359 | 20 | String loc = getContextLocation(); |
360 | 20 | if (loc != null) |
361 | |
{ |
362 | 20 | msg += " at " + loc; |
363 | |
} |
364 | 20 | return msg; |
365 | |
} |
366 | |
|
367 | |
public void setMessage (String msg) |
368 | |
{ |
369 | 10 | _msg = msg; |
370 | 10 | } |
371 | |
} |
372 | |
|
373 | |
} |