1 9 package com.vladium.emma.report; 10 11 import org.apache.tools.ant.BuildException; 12 import org.apache.tools.ant.types.Path; 13 import org.apache.tools.ant.types.Reference; 14 15 import com.vladium.util.IProperties; 16 import com.vladium.emma.ant.FileTask; 17 import com.vladium.emma.ant.SuppressableTask; 18 import com.vladium.emma.report.ReportCfg.Element_HTML; 19 import com.vladium.emma.report.ReportCfg.Element_TXT; 20 import com.vladium.emma.report.ReportCfg.Element_XML; 21 22 26 public 27 final class reportTask extends FileTask implements IReportProperties, IReportEnums 28 { 29 public reportTask (final SuppressableTask parent) 30 { 31 super (parent); 32 } 33 34 public void init () throws BuildException 35 { 36 super.init (); 37 38 m_reportCfg = new ReportCfg (getProject (), this); 39 } 40 41 42 public void execute () throws BuildException 43 { 44 if (isEnabled ()) 45 { 46 final String [] reportTypes = m_reportCfg.getReportTypes (); 47 48 if ((reportTypes == null) || (reportTypes.length == 0)) throw (BuildException) newBuildException (getTaskName () 50 + ": no report types specified: provide at least one of <txt>, <html>, <xml> nested elements", location).fillInStackTrace (); 51 52 String [] files = getDataPath (true); 53 if ((files == null) || (files.length == 0)) 54 throw (BuildException) newBuildException (getTaskName () 55 + ": no valid input data files have been specified", location).fillInStackTrace (); 56 57 final Path srcpath = m_reportCfg.getSourcepath (); 58 59 final IProperties settings; 61 { 62 final IProperties taskSettings = getTaskSettings (); 63 final IProperties reportSettings = m_reportCfg.getReportSettings (); 64 65 settings = IProperties.Factory.combine (reportSettings, taskSettings); 68 } 69 70 final ReportProcessor processor = ReportProcessor.create (); 71 72 processor.setDataPath (files); files = null; 73 processor.setSourcePath (srcpath != null ? srcpath.list () : null); 74 processor.setReportTypes (reportTypes); 75 processor.setPropertyOverrides (settings); 76 77 processor.run (); 78 } 79 } 80 81 82 84 public void setSourcepath (final Path path) 85 { 86 m_reportCfg.setSourcepath (path); 87 } 88 89 public void setSourcepathRef (final Reference ref) 90 { 91 m_reportCfg.setSourcepathRef (ref); 92 } 93 94 public Path createSourcepath () 95 { 96 return m_reportCfg.createSourcepath (); 97 } 98 99 100 102 public Element_TXT createTxt () 103 { 104 return m_reportCfg.createTxt (); 105 } 106 107 public Element_HTML createHtml () 108 { 109 return m_reportCfg.createHtml (); 110 } 111 112 public Element_XML createXml () 113 { 114 return m_reportCfg.createXml (); 115 } 116 117 118 120 public void setUnits (final UnitsTypeAttribute units) 121 { 122 m_reportCfg.setUnits (units); 123 } 124 125 public void setDepth (final DepthAttribute depth) 126 { 127 m_reportCfg.setDepth (depth); 128 } 129 130 public void setColumns (final String columns) 131 { 132 m_reportCfg.setColumns (columns); 133 } 134 135 public void setSort (final String sort) 136 { 137 m_reportCfg.setSort (sort); 138 } 139 140 public void setMetrics (final String metrics) 141 { 142 m_reportCfg.setMetrics (metrics); 143 } 144 145 147 157 159 164 public void setEncoding (final String encoding) 165 { 166 m_reportCfg.setEncoding (encoding); 167 } 168 169 171 173 175 176 private ReportCfg m_reportCfg; 177 178 } | Popular Tags |