01: package org.enhydra.util;
02:
03: import java.io.File;
04: import java.io.FileInputStream;
05: import java.io.FileNotFoundException;
06: import java.util.HashMap;
07:
08: import com.lutris.util.ConfigException;
09: import com.lutris.util.ParseException;
10:
11: public class ConfConfiguration {
12:
13: private String path;
14: private File file;
15: private HashMap results;
16:
17: public ConfConfiguration() {
18: }
19:
20: public HashMap getResults() {
21: return results;
22: }
23:
24: public void parseConfConfiguration(String filePath)
25: throws NullPointerException, FileNotFoundException,
26: ParseException, ConfigException {
27: //System.out.println("method parseConfConfiguration for file= " + filePath);
28: path = filePath;
29:
30: try {
31: file = new File(path);
32: } catch (NullPointerException e) {
33: throw new NullPointerException("File path is null");
34: }
35:
36: //System.out.println(" getAbsolutePath= " + file.getAbsolutePath());
37:
38: ConfConfigurationParser parser;
39: results = new HashMap();
40:
41: try {
42: parser = new ConfConfigurationParser(new FileInputStream(
43: file));
44: parser.process(results);
45: } catch (java.io.FileNotFoundException e) {
46: throw new NullPointerException("File not found");
47: } catch (ParseException e) {
48: throw new ParseException(
49: "Error in processing configuration file");
50: } catch (ConfigException e) {
51: throw new ConfigException(
52: "Configuration error while processing file");
53: }
54: }
55:
56: }
|