1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.millscript.alert;
22
23 import org.millscript.commons.alert.Alert;
24 import org.millscript.commons.alert.alerts.Fault;
25 import org.millscript.commons.alert.alerts.Unimplemented;
26
27 /**
28 * These are utility alerts for MillScript.
29 */
30 public class Alerts {
31
32 /**
33 * Convenience method for constructing a new alert with the specified
34 * complaint and explanation in the autoloading phase.
35 *
36 * @param comp the complaint
37 * @param exp the explanation for the complaint
38 * @return a new alert with the specified complaint and explanation
39 */
40 public static Alert autoload( final String comp, final String exp ) {
41 return new Alert( comp, exp ).setPhase( Phases.AUTOLOAD );
42 }
43
44 /**
45 * Convenience method for constructing a new alert with the specified
46 * complaint and explanation in the compile phase.
47 *
48 * @param comp the complaint
49 * @param exp the explanation for the complaint
50 * @return a new alert with the specified complaint and explanation
51 */
52 public static Alert compile( final String comp, final String exp ) {
53 return new Alert( comp, exp ).setPhase( Phases.COMPILE );
54 }
55
56 /**
57 * Convenience method for constructing a new alert with the specified
58 * complaint and explanation in the evaluation phase.
59 *
60 * @param comp the complaint
61 * @param exp the explanation for the complaint
62 * @return a new alert with the specified complaint and explanation
63 */
64 public static Alert eval( final String comp, final String exp ) {
65 return new Alert( comp, exp ).setPhase( Phases.EVAL );
66 }
67
68 /**
69 * Convenience method for constructing a new alert with the specified
70 * complaint and explanation in the parsing phase.
71 *
72 * @param comp the complaint
73 * @param exp the explanation for the complaint
74 * @return a new alert with the specified complaint and explanation
75 */
76 public static Alert parse( final String comp, final String exp ) {
77 return new Alert( comp, exp ).setPhase( Phases.PARSE );
78 }
79
80 /**
81 * Convenience method for constructing a new alert with the specified
82 * complaint and explanation in the template loading phase.
83 *
84 * @param comp the complaint
85 * @param exp the explanation for the complaint
86 * @return a new alert with the specified complaint and explanation
87 */
88 public static Alert template( final String comp, final String exp ) {
89 return new Alert( comp, exp).setPhase( Phases.TEMPLATE );
90 }
91
92 /**
93 * Utility method for internal fault mishaps. This is just a convenience
94 * for generating an internat fault alert.
95 *
96 * @param msg the mishap complaint
97 * @return a new alert for the specified fault
98 */
99 public static Alert fault( final String msg ) {
100 return new Fault( msg );
101 }
102
103 /**
104 * Utility method for unimplemented mishaps, where you only need to display
105 * a simple message.
106 *
107 * @param msg the unimplemented feature message
108 * @return a new alert for the unimplemented feature
109 */
110 public static Alert unimplemented( final String msg ) {
111 return new Unimplemented( msg );
112 }
113
114 }