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 * EvaluationExceptionHandler
26 *
27 * An interface for specifying how certain classes of errors will be
28 * handled. The handle method is called when an exception is thrown
29 * when trying to expand a variable or property reference. The error
30 * and warning methods are called from directives and context tools to
31 * generate output warnings. Any of these routines may throw exceptions,
32 * in which case the enclosing servlet will catch it and generate an error
33 * which the user sees (useful for debugging.)
34 *
35 * @author Brian Goetz
36 * @since 0.96 */
37
38 package org.webmacro.engine;
39
40 import org.webmacro.Broker;
41 import org.webmacro.Context;
42 import org.webmacro.PropertyException;
43 import org.webmacro.util.Settings;
44
45 public interface EvaluationExceptionHandler
46 {
47
48 /***
49 * Initialize the EEH
50 */
51 public void init (Broker b, Settings config);
52
53 /***
54 * When an exception is detected in the process of expanding (writing)
55 * a variable reference, this method is consulted. It either throws
56 * an exception, or it returns a String which can be written to the
57 * output in place of the property expansion.
58 */
59 public String expand (Variable variable,
60 Context context,
61 Exception problem)
62 throws PropertyException;
63
64 /***
65 * When an exception is detected in the process of evaluating
66 * a variable reference, this method is consulted. It either returns,
67 * in which case the caller is supposed to supply a default value (like
68 * null), or will throw.
69 */
70 public void evaluate (Variable variable,
71 Context context,
72 Exception problem)
73 throws PropertyException;
74
75 public String warningString (String warningText)
76 throws PropertyException;
77
78 public String errorString (String errorText)
79 throws PropertyException;
80
81 }