KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > util > ConfConfiguration


1 package org.enhydra.util;
2
3 import java.io.File JavaDoc;
4 import java.io.FileInputStream JavaDoc;
5 import java.io.FileNotFoundException JavaDoc;
6 import java.util.HashMap JavaDoc;
7
8 import com.lutris.util.ConfigException;
9 import com.lutris.util.ParseException;
10
11 public class ConfConfiguration {
12
13   private String JavaDoc path;
14   private File JavaDoc file;
15   private HashMap JavaDoc results;
16   
17   public ConfConfiguration () {}
18   
19   public HashMap JavaDoc getResults () {
20      return results;
21   }
22   
23   public void parseConfConfiguration (String JavaDoc filePath) throws NullPointerException JavaDoc, FileNotFoundException JavaDoc,
24             ParseException, ConfigException {
25 //System.out.println("method parseConfConfiguration for file= " + filePath);
26
path = filePath;
27      
28     try {
29      file = new File JavaDoc(path);
30     }
31     catch (NullPointerException JavaDoc e){
32       throw new NullPointerException JavaDoc("File path is null");
33     }
34     
35
36 //System.out.println(" getAbsolutePath= " + file.getAbsolutePath());
37

38     ConfConfigurationParser parser;
39     results = new HashMap JavaDoc();
40     
41     try {
42       parser = new ConfConfigurationParser(new FileInputStream JavaDoc(file));
43       parser.process(results);
44     }
45     catch (java.io.FileNotFoundException JavaDoc e){
46       throw new NullPointerException JavaDoc("File not found");
47     }
48     catch (ParseException e){
49       throw new ParseException("Error in processing configuration file");
50     }
51     catch (ConfigException e){
52       throw new ConfigException("Configuration error while processing file");
53     }
54   }
55
56 }
57
58
Popular Tags