KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > cofax > util > InitVars


1 /*
2  * InitVars is part of the Cofax content management sytem library.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Please see http://www.cofax.org for contact information and other
19  * related informaion.
20  *
21  * $Header: /cvsroot/cofax/cofax/src/org/cofax/util/InitVars.java,v 1.4.2.1 2006/12/11 16:30:01 fxrobin Exp $
22  */

23
24 package org.cofax.util;
25
26 import org.cofax.XMLConfig;
27
28 class InitVars {
29
30     public String JavaDoc URL_TO_GET;
31
32     public String JavaDoc FILE_TO_WRITE;
33
34     public String JavaDoc TEMPLATE_FILENAME;
35
36     public String JavaDoc ARTICLE_FILENAME;
37
38     public String JavaDoc SECTION;
39
40     public String JavaDoc PUB_NAME;
41
42     public InitVars(String JavaDoc configFilename) {
43         try {
44             XMLConfig configFile = new XMLConfig();
45             configFile.setXMLFileName(configFilename);
46             configFile.load();
47
48             // SECURITY: TO DO:
49
// Ensure that a valid template path is specified.
50
// Consider giving a warning if the template path is
51
// "/", "c:", "d:/", etc.
52

53             // urlToGet, fileToWrite templateFileName
54
// filename, section
55
URL_TO_GET = configFile.getString("urlToGet");
56             FILE_TO_WRITE = configFile.getString("fileToWrite");
57             TEMPLATE_FILENAME = configFile.getString("templateFilename");
58             ARTICLE_FILENAME = configFile.getString("articleFilename");
59             SECTION = configFile.getString("section");
60             PUB_NAME = configFile.getString("pubName");
61
62         } catch (Exception JavaDoc e) {
63
64             System.err.println("Error reading configuration:");
65             e.printStackTrace(System.err);
66
67         }
68     }
69 }
70
Popular Tags