View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Kevin Rogers
4   //
5   // This file is part of MillScript.
6   //
7   // MillScript is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
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 }