1 package org.enhydra.util; 2 3 import java.io.File ; 4 import java.io.FileInputStream ; 5 import java.io.FileNotFoundException ; 6 import java.util.HashMap ; 7 8 import com.lutris.util.ConfigException; 9 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 public HashMap getResults () { 20 return results; 21 } 22 23 public void parseConfConfiguration (String filePath) throws NullPointerException , FileNotFoundException , 24 ParseException, ConfigException { 25 path = filePath; 27 28 try { 29 file = new File (path); 30 } 31 catch (NullPointerException e){ 32 throw new NullPointerException ("File path is null"); 33 } 34 35 36 38 ConfConfigurationParser parser; 39 results = new HashMap (); 40 41 try { 42 parser = new ConfConfigurationParser(new FileInputStream (file)); 43 parser.process(results); 44 } 45 catch (java.io.FileNotFoundException e){ 46 throw new NullPointerException ("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 |