Coverage report

  %line %branch
com.wikihouse.wildcats0201.jdbcchart.dom4j.XMLParserFactory
33% 
100% 

 1  
 package com.wikihouse.wildcats0201.jdbcchart.dom4j;
 2  
 
 3  
 import java.util.Iterator;
 4  
 
 5  
 import org.dom4j.Document;
 6  
 import org.dom4j.DocumentException;
 7  
 import org.dom4j.Element;
 8  
 
 9  
 import com.wikihouse.wildcats0201.jdbcchart.dto.ChartFile;
 10  
 import com.wikihouse.wildcats0201.jdbcchart.dto.ChartXMLDTO;
 11  
 import com.wikihouse.wildcats0201.jdbcchart.dto.Item;
 12  
 import com.wikihouse.wildcats0201.jdbcchart.dto.Label;
 13  
 import com.wikihouse.wildcats0201.jdbcchart.dto.SQL;
 14  
 
 15  
 /**
 16  
  * <B>XMLParserFactory </B>. XMLParserのFactoryです。
 17  
  * 
 18  
  * @author $Author: wildcats $
 19  
  * @version $Revision: 5 $
 20  
  */
 21  
 public final class XMLParserFactory {
 22  
 
 23  0
     private XMLParserFactory() {
 24  0
     }
 25  
 
 26  
     /**
 27  
      * 生成.
 28  
      * 
 29  
      * @return XMLParser
 30  
      */
 31  
     public static XMLParser create() {
 32  6
         return new XMLParseImpl();
 33  
     }
 34  
 
 35  
     /**
 36  
      * <B>XMLParseImpl </B>. XMLParserの実装です。
 37  
      * 
 38  
      * @todo Validation未実装
 39  
      * @author $Author: wildcats $
 40  
      * @version $Revision: 5 $
 41  
      */
 42  
     private static class XMLParseImpl implements XMLParser {
 43  
 
 44  
         /**
 45  
          * @see com.wikihouse.wildcats0201.jdbcchart.dom4j.XMLParser#read(java.lang.String)
 46  
          */
 47  
         public ChartXMLDTO read(String fileName) {
 48  
             SAXReaderWrapper parser = SAXReaderWrapperFactory.create();
 49  
             Document document = null;
 50  
             try {
 51  
                 document = parser.parse(fileName);
 52  
             } catch (DocumentException e) {
 53  
                 throw new RuntimeException(e);
 54  
             }
 55  
             Element root = document.getRootElement();
 56  
 
 57  
             Element labelElement = root.element("label");
 58  
 
 59  
             ChartXMLDTO data = new ChartXMLDTO();
 60  
 
 61  
             Label label = new Label(labelElement.attributeValue("title"),
 62  
                     labelElement.attributeValue("xLabel"), labelElement
 63  
                             .attributeValue("yLabel"));
 64  
 
 65  
             data.setLabel(label);
 66  
 
 67  
             Element seriesElement = root.element("series");
 68  
             for (Iterator i = seriesElement.elementIterator("item"); i
 69  
                     .hasNext();) {
 70  
                 Element itemElement = (Element) i.next();
 71  
                 Item item = new Item(itemElement.attributeValue("name"));
 72  
                 data.addSeries(item);
 73  
             }
 74  
 
 75  
             Element fileElement = root.element("file");
 76  
             ChartFile file = new ChartFile(fileElement.attributeValue("path"),
 77  
                     fileElement.attributeValue("name"), fileElement
 78  
                             .attributeValue("type"), getIntValue(fileElement
 79  
                             .attributeValue("width")), getIntValue(fileElement
 80  
                             .attributeValue("height")));
 81  
 
 82  
             data.setFile(file);
 83  
 
 84  
             Element sqlElement = root.element("sql");
 85  
             SQL sql = new SQL(sqlElement.getText());
 86  
             data.setSQL(sql);
 87  
             return data;
 88  
         }
 89  
 
 90  
         private int getIntValue(String string) {
 91  
             return Integer.parseInt(string);
 92  
         }
 93  
 
 94  
     }
 95  
 
 96  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.