@@ -0,0 +1,2013 @@
+package edu.colorado.csdms.heat;%0A%0Aimport java.io.File;%0Aimport java.util.HashMap;%0A%0Aimport javax.xml.parsers.DocumentBuilder;%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0A%0Aimport org.w3c.dom.Document;%0Aimport org.w3c.dom.NamedNodeMap;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0A%0A/**%0A * Represents a model configuration file containing parameter values for the%0A * heat model.%0A */%0Apublic class HeatConfigFile %7B%0A  %0A  private String fileName;%0A  private Document doc = null;%0A  private HashMap%3CString, Double%3E parameters;%0A%0A  /**%0A   * Makes an instance of HeatConfigFile.%0A   * %0A   * @param fileName the path to the configuration file%0A   */%0A  public HeatConfigFile(String fileName) %7B%0A    this.fileName = fileName;%0A    this.parameters = new HashMap%3CString, Double%3E();%0A  %7D%0A  %0A  /**%0A   * Extracts parameter names and values from the file.%0A   * %0A   * @return a %7B@link HashMap%7D with parameter names and values%0A   */%0A  public HashMap%3CString, Double%3E load() %7B%0A    loadFile();%0A    parseParameters();%0A    return parameters;%0A  %7D%0A%0A  /**%0A   * Load the contents of an XML file.%0A   * %0A   * @param fileName the name of the XML file%0A   * @return the file contents as a Document%0A   */%0A  private void loadFile() %7B%0A    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();%0A    DocumentBuilder db;%0A    %0A    try %7B%0A      db = dbf.newDocumentBuilder();%0A      doc = db.parse(new File(fileName));%0A    %7D catch (Exception e) %7B%0A      e.printStackTrace();%0A    %7D%0A  %7D%0A%0A  /**%0A   * Parse parameter names and values from the XML document.%0A   */%0A  private void parseParameters() %7B%0A    Node modelNode = doc.getLastChild();%0A    NodeList list = modelNode.getChildNodes();%0A    %0A    for (int i = 0; i %3C list.getLength(); i++) %7B%0A      Node node = list.item(i);%0A      if (node.getNodeName().equals(%22parameter%22)) %7B%0A        NamedNodeMap attr = node.getAttributes();%0A        String key = attr.item(0).getNodeValue();%0A        Double value = Double.valueOf(attr.item(1).getNodeValue());%0A        parameters.put(key, value);%0A      %7D%0A    %7D%0A  %7D%0A%7D%0A

Add class to read parameters from model config file