Coverage report

  %line %branch
com.wikihouse.wildcats0201.jdbcchart.ant.XyLineChartTask
0% 
0% 

 1  
 package com.wikihouse.wildcats0201.jdbcchart.ant;
 2  
 
 3  
 import java.io.File;
 4  
 import java.text.MessageFormat;
 5  
 import java.util.Iterator;
 6  
 import java.util.LinkedList;
 7  
 import java.util.List;
 8  
 
 9  
 import org.apache.tools.ant.BuildException;
 10  
 import org.apache.tools.ant.DirectoryScanner;
 11  
 import org.apache.tools.ant.Project;
 12  
 import org.apache.tools.ant.Task;
 13  
 import org.apache.tools.ant.loader.AntClassLoader2;
 14  
 import org.apache.tools.ant.types.FileSet;
 15  
 import org.apache.tools.ant.types.Path;
 16  
 import org.apache.tools.ant.types.Reference;
 17  
 
 18  
 import com.wikihouse.wildcats0201.jdbcchart.XYChartByJDBC;
 19  
 
 20  
 /**
 21  
  * <B>XyLineChartTask </B>. Chartの作成を行うAntタスクです。
 22  
  * 
 23  
  * @author $Author: wildcats $
 24  
  * @version $Revision: 5 $
 25  
  */
 26  0
 public class XyLineChartTask extends Task {
 27  
 
 28  0
     private List fileList = new LinkedList();
 29  
 
 30  
     private Path classpath;
 31  
 
 32  
     private String driver;
 33  
 
 34  
     private String user;
 35  
 
 36  
     private String password;
 37  
 
 38  
     private String url;
 39  
 
 40  
     /**
 41  
      * FileSetを生成し返却します。
 42  
      * 
 43  
      * @return FileSet
 44  
      */
 45  
     public FileSet createFileSet() {
 46  0
         FileSet fs = new FileSet();
 47  0
         fileList.add(fs);
 48  0
         return fs;
 49  
     }
 50  
 
 51  
     private String[] getUrlPaths() {
 52  0
         List list = new LinkedList();
 53  
 
 54  0
         for (Iterator it = this.fileList.iterator(); it.hasNext();) {
 55  0
             FileSet fileset = (FileSet) it.next();
 56  0
             DirectoryScanner scanner = fileset
 57  
                     .getDirectoryScanner(getProject());
 58  0
             String[] files = scanner.getIncludedFiles();
 59  0
             StringBuffer sb = new StringBuffer();
 60  0
             for (int i = 0; i < files.length; i++) {
 61  0
                 sb.append(scanner.getBasedir().getAbsolutePath());
 62  0
                 sb.append(File.separatorChar);
 63  0
                 sb.append(files[i]);
 64  0
                 list.add(sb.toString());
 65  0
                 log(MessageFormat.format("target file [{0}]", new Object[] { sb
 66  
                         .toString() }));
 67  0
                 sb.delete(0, sb.length());
 68  
             }
 69  
         }
 70  0
         return (String[]) list.toArray(new String[list.size()]);
 71  
     }
 72  
 
 73  
     /**
 74  
      * クラスパスのReferenceを設定します。
 75  
      * 
 76  
      * @param r
 77  
      *            Reference
 78  
      */
 79  
     public void setClasspathRef(Reference r) {
 80  0
         createClasspath().setRefid(r);
 81  0
     }
 82  
 
 83  
     /**
 84  
      * クラスパスを設定します。
 85  
      * 
 86  
      * @param classpath
 87  
      *            クラスパス
 88  
      */
 89  
     public void setClasspath(Path classpath) {
 90  0
         if (this.classpath == null) {
 91  0
             this.classpath = classpath;
 92  
         } else {
 93  0
             this.classpath.append(classpath);
 94  
         }
 95  0
     }
 96  
 
 97  
     /**
 98  
      * クラスパスを返却します。
 99  
      * 
 100  
      * @return クラスパス
 101  
      */
 102  
     public Path createClasspath() {
 103  0
         if (this.classpath == null) {
 104  0
             this.classpath = new Path(getProject());
 105  
         }
 106  0
         return this.classpath;
 107  
     }
 108  
 
 109  
     /**
 110  
      * JDBCドライバを設定します。
 111  
      * 
 112  
      * @param driver
 113  
      *            JDBCドライバ名
 114  
      * @todo Validation未実装
 115  
      */
 116  
     public void setDriver(String driver) {
 117  0
         this.driver = driver;
 118  0
     }
 119  
 
 120  
     /**
 121  
      * JDBC接続URLを設定します。
 122  
      * 
 123  
      * @param url
 124  
      *            JDBC接続URL
 125  
      * @todo Validation未実装
 126  
      */
 127  
     public void setUrl(String url) {
 128  0
         this.url = url;
 129  0
     }
 130  
 
 131  
     /**
 132  
      * データベースパスワードを設定します。
 133  
      * 
 134  
      * @param password
 135  
      *            パスワード
 136  
      */
 137  
     public void setPassword(String password) {
 138  0
         this.password = password;
 139  0
     }
 140  
 
 141  
     /**
 142  
      * データベースユーザ名を設定します。
 143  
      * 
 144  
      * @param user
 145  
      *            ユーザ名
 146  
      */
 147  
     public void setUser(String user) {
 148  0
         this.user = user;
 149  0
     }
 150  
 
 151  
     /**
 152  
      * @see org.apache.tools.ant.Task#execute()
 153  
      */
 154  
     public void execute() throws BuildException {
 155  0
         AntClassLoader2 loader = (AntClassLoader2) this.getClass()
 156  
                 .getClassLoader();
 157  0
         loader.setClassPath(this.classpath);
 158  
 
 159  0
         log(loader.getClasspath(), Project.MSG_INFO);
 160  
 
 161  0
         String[] files = this.getUrlPaths();
 162  0
         for (int i = 0; i < files.length; i++) {
 163  0
             XYChartByJDBC xyChartByJDBC = new XYChartByJDBC();
 164  0
             xyChartByJDBC.execute(files[i], this.driver, class="keyword">this.url, class="keyword">this.user,
 165  
                     this.password);
 166  
         }
 167  
 
 168  0
     }
 169  
 
 170  
 }

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