Beispiel #1
0
 /**
  * Parses an XML config file.
  *
  * @param filename The path to the file to parse.
  */
 public void parse(String filename) throws ConfigException {
   try {
     String xml = Utils.fileToString(filename);
     JSONObject jobj = XML.toJSONObject(xml);
     configObject = (Map) new JSONReader(jobj.toString()).readObject();
   } catch (Exception e) {
     throw new ConfigException("Error parsing config", e);
   }
 }
Beispiel #2
0
 /**
  * Returns the configuration object found at the requested path.
  *
  * @param path The search path
  * @return The config value
  * @throws ConfigException thrown if nothing is found at the path
  */
 public Object get(String path) throws ConfigException {
   try {
     Object obj = Utils.findPath(configObject, context + path);
     if (obj == null) throw new ConfigException("");
     return obj;
   } catch (Exception e) {
     e.printStackTrace();
     throw new ConfigException("No config object found at " + path);
   }
 }