Clover coverage report -
Coverage timestamp: Do Okt 21 2004 12:21:23 CEST
file stats: LOC: 67   Methods: 2
NCLOC: 39   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultConfigParser.java 87,5% 100% 100% 96,9%
coverage coverage
 1    /*
 2    * XMLConfigParser.java
 3    *
 4    * Created on 12. Dezember 2002, 22:02
 5    */
 6   
 7    package org.jconfig.parser;
 8   
 9    import org.jconfig.Configuration;
 10    import org.jconfig.DefaultConfiguration;
 11    import org.w3c.dom.Document;
 12    import org.w3c.dom.NamedNodeMap;
 13    import org.w3c.dom.Node;
 14    import org.w3c.dom.NodeList;
 15    /**
 16    *
 17    * @author Andreas Mecky andreas.mecky@xcom.de
 18    * @author Terry Dye terry.dye@xcom.de
 19    */
 20    public class DefaultConfigParser extends AbstractConfigParser {
 21   
 22  10 public DefaultConfigParser() {
 23    }
 24   
 25    /**
 26    * Description of the Method
 27    *
 28    *@param doc Description of the Parameter
 29    */
 30  10 public Configuration parse(Document doc,String configName) {
 31  10 Configuration configuration = new DefaultConfiguration(configName);
 32  10 String currentCategory;
 33  10 getBaseConfigName(doc, configuration);
 34  10 getVariables(doc,configuration);
 35  10 getIncludeProperties(doc, configuration);
 36    // first we get all nodes where the element is category
 37  10 NodeList nl = doc.getElementsByTagName("category");
 38  10 for (int i = 0; i < nl.getLength(); i++) {
 39    // now we get every node from the list
 40  42 Node n = nl.item(i);
 41    // and get the name attribute for this category
 42  42 NamedNodeMap curAtt = n.getAttributes();
 43  42 Node curNode = curAtt.getNamedItem("name");
 44  42 currentCategory = curNode.getNodeValue();
 45  42 configuration.setCategory(currentCategory);
 46    // now we process all children for this category
 47  42 for (Node child = n.getFirstChild(); child != null; child = child.getNextSibling()) {
 48  388 if (child.getNodeName().equals("property")) {
 49    // we have found a property element and now we grab the name and value
 50    // attributes
 51  155 NamedNodeMap myAtt = child.getAttributes();
 52  155 Node myNode = myAtt.getNamedItem("name");
 53  155 String name = myNode.getNodeValue();
 54  155 myNode = myAtt.getNamedItem("value");
 55  155 String value = myNode.getNodeValue();
 56    // if we have both then lets store it
 57  155 if (name != null && value != null) {
 58    // the key is always category/name
 59    // e.g. general/congig_file
 60  155 configuration.setProperty(name,value,currentCategory);
 61    }
 62    }
 63    }
 64    }
 65  10 return configuration;
 66    }
 67    }