1 7 package org.objectweb.rentacar.util; 8 9 import java.io.IOException ; 10 import java.io.InputStream ; 11 12 import org.jdom.Document; 13 import org.jdom.JDOMException; 14 import org.jdom.input.SAXBuilder; 15 16 21 public class ConfigHelper { 22 23 24 30 public static Document getConfig(String XMLfile) throws RentacarUtilException { 31 Document doc = null; 32 String myFile = StringHelper.isEmpty(XMLfile) ? "rentacar.cfg.xml" : XMLfile; 33 InputStream myInputStream = ConfigHelper.class.getResourceAsStream("/"+myFile); 34 if (myInputStream == null) { 35 throw new ExceptionInInitializerError ("unable to find configuration file"); 37 } 38 try { 39 doc =parseXmlFile(myInputStream); 40 } catch (JDOMException e) { 41 throw new RentacarUtilException("Error in JDOM parsing", e); 42 } catch (IOException e) { 43 throw new RentacarUtilException("Error in JDOM parsing", e); 44 } 45 return doc; 46 47 } 48 49 52 public boolean isValid(String XMLfile) { 53 return true; 54 } 55 56 62 private static Document parseXmlFile(InputStream xmlURL) throws JDOMException, IOException { 63 Document document = null; 64 SAXBuilder sxb = new SAXBuilder(); 65 document = sxb.build(xmlURL); 66 return document; 67 } 68 69 } 70 | Popular Tags |