Clover coverage report - PMD - 3.3
Coverage timestamp: Thu Sep 15 2005 17:59:57 EDT
file stats: LOC: 148   Methods: 20
NCLOC: 102   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
RuleViolation.java 87.5% 88.1% 80% 85.7%
coverage coverage
 1    /**
 2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 3    */
 4    package net.sourceforge.pmd;
 5   
 6    import java.util.Comparator;
 7   
 8    public class RuleViolation {
 9   
 10    public static class RuleViolationComparator implements Comparator {
 11    //
 12    // Changed logic of Comparator so that rules in the same file
 13    // get grouped together in the output report.
 14    // DDP 7/11/2002
 15    //
 16  17682 public int compare(Object o1, Object o2) {
 17  17682 RuleViolation r1 = (RuleViolation) o1;
 18  17682 RuleViolation r2 = (RuleViolation) o2;
 19  17682 if (!r1.getFilename().equals(r2.getFilename())) {
 20  9 return r1.getFilename().compareTo(r2.getFilename());
 21    }
 22   
 23  17673 if (r1.getLine() != r2.getLine())
 24  17666 return r1.getLine() - r2.getLine();
 25   
 26  7 if (r1.getDescription() != null && r2.getDescription() != null && !r1.getDescription().equals(r2.getDescription())) {
 27  4 return r1.getDescription().compareTo(r2.getDescription());
 28    }
 29   
 30  3 if (r1.getLine() == r2.getLine()) {
 31  3 return 1;
 32    }
 33   
 34    // line number diff maps nicely to compare()
 35  0 return r1.getLine() - r2.getLine();
 36    }
 37    }
 38   
 39    private int line;
 40    private Rule rule;
 41    private String description;
 42    private String filename;
 43    private int line2 = -1;
 44    private String packageName;
 45    private String className;
 46    private String methodName;
 47    private String variableName;
 48    private int beginColumn = -1;
 49    private int endColumn = -1;
 50   
 51    /**
 52    * gets the character in the line where the violation starts
 53    * @return a greater than or zero if set and a negative value if not available
 54    */
 55  0 public final int getBeginColumn() {
 56  0 return beginColumn;
 57    }
 58    /**
 59    * gets the character in the line where the violation ends
 60    * @return a greater than or zero if set and a negative value if not available
 61    */
 62  0 public final int getEndColumn() {
 63  0 return endColumn;
 64    }
 65    /**
 66    * sets both beginColumn and endColumn
 67    * @param begin
 68    * @param end
 69    */
 70  3218 public void setColumnInfo(int begin, int end) {
 71  3218 this.beginColumn = begin;
 72  3218 this.endColumn = end;
 73    }
 74   
 75  99 public RuleViolation(Rule rule, int line, RuleContext ctx, String packageName, String className, String methodName) {
 76  99 this(rule, line, rule.getMessage(), ctx, packageName, className, methodName);
 77    }
 78   
 79  3229 public RuleViolation(Rule rule, int line, String specificDescription, RuleContext ctx, String packageName, String className, String methodName) {
 80  3229 this(rule, line, -1, "", specificDescription, ctx, packageName, className, methodName);
 81    }
 82   
 83  3229 public RuleViolation(Rule rule, int line, int line2, String variableName, String specificDescription, RuleContext ctx, String packageName, String className, String methodName) {
 84  3229 this.line = line;
 85  3229 this.line2 = line2;
 86  3229 this.rule = rule;
 87  3229 this.description = specificDescription;
 88  3229 this.filename = ctx.getSourceCodeFilename();
 89  3229 this.packageName = packageName;
 90  3229 this.className = className;
 91  3229 this.methodName = methodName;
 92  3229 this.variableName = variableName;
 93    }
 94   
 95  16 public RuleViolation(Rule rule, int line, String specificDescription, RuleContext ctx) {
 96  16 this.line = line;
 97  16 this.rule = rule;
 98  16 this.description = specificDescription;
 99  16 this.filename = ctx.getSourceCodeFilename();
 100    }
 101   
 102  88 public RuleViolation(AbstractRule rule, RuleContext ctx, String packageName, String className, String methodName) {
 103  88 this(rule, 0, ctx, packageName, className, methodName);
 104    }
 105   
 106  69 public Rule getRule() {
 107  69 return rule;
 108    }
 109   
 110  220577 public int getLine() {
 111  220577 return line;
 112    }
 113   
 114  57 public String getDescription() {
 115  57 return description;
 116    }
 117   
 118  182059 public String getFilename() {
 119  182059 return filename;
 120    }
 121   
 122  3246 public String getClassName() {
 123  3246 return className;
 124    }
 125   
 126  13 public String getMethodName() {
 127  13 return methodName;
 128    }
 129   
 130  0 public int getLine2() {
 131  0 return line2;
 132    }
 133   
 134  3246 public String getPackageName() {
 135  3246 return packageName;
 136    }
 137   
 138  10 public String getVariableName() {
 139  10 return variableName;
 140    }
 141   
 142  0 public String toString() {
 143  0 return getFilename() + ":" + getRule() + ":" + getDescription() + ":" + getLine();
 144    }
 145  3218 public final void setLine(int line) {
 146  3218 this.line = line;
 147    }
 148    }