View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2004-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.conf;
22  
23  import org.millscript.commons.alert.Alert;
24  import org.millscript.commons.vfs.VFS;
25  import org.millscript.commons.vfs.VFile;
26  import org.millscript.commons.vfs.VFolder;
27  import org.millscript.millscript.conf.logging.Logger;
28  import org.millscript.millscript.loaders.LoaderBuilder;
29  import org.millscript.millscript.tools.CharacterEntity;
30  import org.millscript.millscript.vm.Engine;
31  import org.millscript.millscript.vm.Package;
32  
33  import java.nio.charset.Charset;
34  
35  /**
36   * Configuration interface, to be implemented by classes wanting to configure a
37   * MillScript engine.
38   */
39  public interface Configuration {
40  
41      /**
42       * Cache folder name.
43       */
44      String CACHE_NAME = "cache";
45  
46      /**
47       * Configuration folder name.
48       */
49      String CONF_NAME = "conf";
50  
51      /**
52       * Hidden website identification folder name.
53       */
54      String DOT_WEBSITE_NAME = ".website";
55  
56      /**
57       * User configuration file name.
58       */
59      String USER_CONF_FILE = "millscript.global.conf";
60  
61      /**
62       * Inventory folder name.
63       */
64      String INVENTORY_NAME = "inventory";
65  
66      /**
67       * Library folder name.
68       */
69      String LIB_NAME = "classes";
70  
71      /**
72       * Output folder name.
73       */
74      String OUTPUT_NAME = "output";
75  
76      /**
77       * Package configuration file name.
78       */
79      String PACKAGE_CONF_FILE = "package.conf";
80  
81      /**
82       * Var folder name.
83       */
84      String VAR_NAME = "var";
85  
86      /**
87       * Website configuration file name.
88       */
89      String WEBSITE_CONF_FILE = "website.conf";
90  
91      /**
92       * Website failure file name.
93       */
94      String WEBSITE_FAILURE_FILE = "dirty.log";
95  
96      /**
97       * Website lock file name.
98       */
99      String WEBSITE_LOCK_FILE = "mill.pid";
100 
101     /**
102      * Website sucess file name.
103      */
104     String WEBSITE_SUCCESSS_FILE = "done.log";
105 
106     /**
107      * Returns the boolean configuration value associated with the specified
108      * key.
109      *
110      * @param key   the key to retrieve a value for
111      * @return  the boolean value associated with the specified key.
112      */
113     boolean getBooleanProperty( final String key );
114 
115     /**
116      * Returns the HTML character entity encoder/decoder object.
117      *
118      * @return  the HTML character entity encoder/decoder.
119      */
120     CharacterEntity getHTMLCharacterEntity();
121 
122     /**
123      * Returns the XML character entity encoder/decoder object.
124      *
125      * @return  the XML character entity encoder/decoder.
126      */
127     CharacterEntity getXMLCharacterEntity();
128 
129     /**
130      * Returns the current working folder.
131      *
132      * @return a VFolder object for the current working folder.
133      */
134     VFolder getCurrentWorkingFolder();
135 
136     /**
137      * Returns the prompt MillScript should use during a session. This should
138      * be <code>null</code> for an batch session and whatever string the user
139      * desires for an interactive session.
140      *
141      * @return  a String containing the interactive prompt
142      */
143     String getInteractivePrompt();
144 
145     /**
146      * Returns the LoaderBuilder for this configuration.
147      *
148      * @return  the LoaderBuilder for this configuration
149      */
150     LoaderBuilder getLoaderBuilder();
151 
152     /**
153      * Returns the logger for this configuration.
154      *
155      * @return    the logger for this configuration
156      */
157     Logger getLogger();
158 
159     /**
160      * Returns the current output character set.
161      *
162      * @return  the current Charset to use for output
163      */
164     Charset getOutputCharset();
165 
166     /**
167      * Returns the location of the package configuration file for the specified
168      * package location.
169      *
170      * @param packageDir    the location of a package
171      * @return  the VFile for the package configuration file, for the specified
172      * pacakge.
173      */
174     VFile getPackageConfFile( final VFolder packageDir );
175 
176     /**
177      * Returns the configuration value associated with the specified key.
178      *
179      * @param key   the key to retrieve a value for
180      * @return  a String holding the value associated with the specified key.
181      */
182     String getProperty( final String key );
183 
184     /**
185      * Returns the location of the standard configuration folder.
186      *
187      * @return  a VFolder object pointing to the standard configuration folder.
188      */
189     VFolder getStandardConfFolder();
190 
191     /**
192      * Returns the location of the user configuration file.
193      *
194      * @return  a VFile object pointing to the user configuration file.
195      */
196     VFile getStandardConfigurationFile();
197 
198     /**
199      * Returns the standard engine for this configuration. The standard engine
200      * may contain a number of builtin packages, e.g. the "standard"
201      * <code>Package</code>.
202      *
203      * @return  the standard <code>Engine</code> for this configuration
204      */
205     Engine getStandardEngine();
206 
207     /**
208      * Returns the location of the standard inventory.
209      *
210      * @return  a VFolder object pointing to the standard inventory folder.
211      */
212     VFolder getStandardInventoryFolder();
213 
214     /**
215      * Returns the location of the standard library folder.
216      *
217      * @return  a VFolder object pointing to the standard library folder.
218      */
219     VFolder getStandardLibFolder();
220 
221     /**
222      * Returns the standard package for this configuration. This includes all
223      * the builtin variables and functions that are appropriate.
224      *
225      * @param engine    the engine this package is associated with
226      * @return  the standard <code>Package</code> for this configuration
227      */
228     Package getStandardPackage( Engine engine );
229 
230     /**
231      * Returns the location of the websites cache folder.
232      *
233      * @return  a VFolder object pointing to the websites cache folder.
234      */
235     VFolder getWebsiteCacheFolder();
236 
237     /**
238      * Returns the location of the websites configuration folder.
239      *
240      * @return  a VFolder object pointing to the websites configuration folder.
241      */
242     VFolder getWebsiteConfFolder();
243 
244     /**
245      * Returns the location of the website configuration file.
246      *
247      * @return  a VFile object pointing to the website configuration file.
248      */
249     VFile getWebsiteConfigurationFile();
250 
251     /**
252      * Returns the location of the website lock file.
253      *
254      * @return  a VFile object pointing to the website lock file.
255      */
256     VFile getWebsiteFailureFile();
257 
258     /**
259      * Returns the location of the websites inventory. This is the inventory
260      * associated with the website script.
261      *
262      * @return  a VFolder object pointing to the websites inventory folder.
263      */
264     VFolder getWebsiteInventoryFolder();
265 
266     /**
267      * Returns the location of the websites library folder.
268      *
269      * @return  a VFolder object pointing to the websites library folder.
270      */
271     VFolder getWebsiteLibFolder();
272 
273     /**
274      * Returns the location of the website lock file.
275      *
276      * @return  a VFile object pointing to the website lock file.
277      */
278     VFile getWebsiteLockFile();
279 
280     /**
281      * Returns the location of the websites output folder.
282      *
283      * @return  a VFolder object pointing to the websites output folder.
284      */
285     VFolder getWebsiteOutputFolder();
286 
287     /**
288      * Returns the location of the website success file.
289      *
290      * @return  a VFile object pointing to the website success file.
291      */
292     VFile getWebsiteSuccessFile();
293 
294     /**
295      * Returns the location of the websites var folder.
296      *
297      * @return  a VFolder object pointing to the websites var folder.
298      */
299     VFolder getWebsiteVarFolder();
300 
301     /**
302      * Returns the VFS this configuration is using.
303      *
304      * @return	the VFS this configuration is using
305      */
306     VFS getVFS();
307 
308     /**
309      * Reports the specified Alert as a mishap. This is the general purpose
310      * method of reporting an Alert.
311      *
312      * @param alert the Alert to report as a mishap
313      */
314     void reportAlertAsMishap( final Alert alert );
315 
316     /**
317      * Reports the specified Alert as a warning. This is the method to use when
318      * reporting an Alert as a warning. For general use, use
319      * {@link #reportAlertAsMishap(Alert)}.
320      *
321      * @param alert the Alert to report as a warning
322      */
323     void reportAlertAsWarning( final Alert alert );
324 
325     /**
326      * Reports the specified Exception.
327      *
328      * @param exception the Exception to report
329      */
330     void reportException( final Exception exception );
331 
332     /**
333      * Sets the logger for this configuration.
334      *
335      * @param logger    the new logger for this configuration
336      */
337     void setLogger( final Logger logger );
338 
339     /**
340      * Sets the output character set.
341      *
342      * @param cs    the Charset to use for output
343      */
344     void setOutputCharset( final Charset cs );
345 
346     /**
347      * Associated the configuration value with the specified key.
348      *
349      * @param key   the key to associate a value with
350      * @param value   the value to associate with the key
351      */
352     void setProperty( final String key, final Object value );
353 
354 }