EMMA Coverage Report (generated Wed Dec 16 17:19:59 CET 2009)
[all classes][org.sourceforge.xradar.ant]

COVERAGE SUMMARY FOR SOURCE FILE [ResultsAnalyserTask.java]

nameclass, %method, %block, %line, %
ResultsAnalyserTask.java0%   (0/1)0%   (0/8)0%   (0/107)0%   (0/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResultsAnalyserTask0%   (0/1)0%   (0/8)0%   (0/107)0%   (0/29)
ResultsAnalyserTask (): void 0%   (0/1)0%   (0/6)0%   (0/2)
addRule (Rule): void 0%   (0/1)0%   (0/14)0%   (0/4)
execute (): void 0%   (0/1)0%   (0/60)0%   (0/14)
getRules (): List 0%   (0/1)0%   (0/3)0%   (0/1)
isFailOnError (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
setFailOnError (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
setRules (List): void 0%   (0/1)0%   (0/4)0%   (0/2)
validate (): void 0%   (0/1)0%   (0/13)0%   (0/3)

1/**
2 * 
3 */
4package org.sourceforge.xradar.ant;
5 
6import java.util.ArrayList;
7import java.util.List;
8 
9import org.apache.tools.ant.BuildException;
10import org.apache.tools.ant.Task;
11import org.sourceforge.xradar.XRadarException;
12import org.sourceforge.xradar.results.AnalysingProcess;
13import org.sourceforge.xradar.results.Rule;
14import org.sourceforge.xradar.results.Violation;
15import org.sourceforge.xradar.results.XRadarResultsAnalyserException;
16 
17/**
18 * 
19 * <code>
20 * <xradar-analyser failOnError="true|false">
21 *         <rule name="rule1" type="xpath" query="//xpath"/> 
22 *  <rule name="rule2" type="xpath" query="//xpath"/>
23 *  ...
24 * </xradar-analyser>
25 * </code>
26 * @author Romain PELISSE, belaran@gmail.com
27 * 
28 * 
29 * 
30 */
31public class ResultsAnalyserTask extends Task {
32 
33        private List<Rule> rules;
34        private boolean failOnError = false;
35 
36        public void addRule(Rule rule)
37        {
38                if ( this.rules == null )
39                        this.rules = new ArrayList<Rule>();
40                this.rules.add(rule);
41        }
42        
43        public boolean isFailOnError() {
44                return failOnError;
45        }
46 
47        public void setFailOnError(boolean failOnError) {
48                this.failOnError = failOnError;
49        }
50 
51        @Override
52        public void execute() throws BuildException {
53                validate();
54                AnalysingProcess analysingEngine = new AnalysingProcess();
55                analysingEngine.setViolations(new ArrayList<Violation>());
56                try {
57                        List<Violation> violations = analysingEngine.analyseResults(rules);
58                        
59                        for ( Violation violation : violations ) {
60                                log(violation.toString());
61                                if ( failOnError )
62                                        throw new BuildException("XRadar analyser violation:" + violation);
63                        }
64                } catch (XRadarResultsAnalyserException e) {
65                        throw new BuildException(e);
66                } catch (XRadarException e) {
67                        throw new BuildException(e);
68                }
69        }
70 
71        private void validate() throws BuildException {
72                if ( rules == null || rules.size() <= 0 )
73                        throw new BuildException("at least on nested element 'rule' is required.");
74        }
75        
76        public List<Rule> getRules() {
77                return rules;
78        }
79 
80        public void setRules(List<Rule> rules) {
81                this.rules = rules;
82        }
83}

[all classes][org.sourceforge.xradar.ant]
EMMA 2.0.5312 (C) Vladimir Roubtsov