1 package net.sourceforge.pmd.stat;
2
3 import net.sourceforge.pmd.Rule;
4
5 import java.util.Random;
6
7 /***
8 * @author David Dixon-Peugh
9 * Aug 8, 2002 DataPoint.java
10 */
11 public class DataPoint implements java.lang.Comparable {
12 private int lineNumber;
13 private int random;
14 private double score;
15 private String message;
16 private Rule rule;
17
18 /***
19 * Constructor for DataPoint.
20 */
21 public DataPoint() {
22 super();
23 // Random number is so that the TreeSet doesn't
24 // whack things with the same score.
25 Random rand = new Random();
26 random = rand.nextInt(11061973);
27 }
28
29 public int compareTo(Object object) {
30
31 DataPoint rhs = (DataPoint) object;
32
33 Double lhsScore = new Double(score);
34 Double rhsScore = new Double(rhs.getScore());
35
36 if (lhsScore.doubleValue() != rhsScore.doubleValue()) {
37 return lhsScore.compareTo(rhsScore);
38 }
39
40 Integer lhsRand = new Integer(random);
41 Integer rhsRand = new Integer(rhs.random);
42
43 return lhsRand.compareTo(rhsRand);
44 }
45
46 /***
47 * Returns the lineNumber.
48 * @return int
49 */
50 public int getLineNumber() {
51 return lineNumber;
52 }
53
54 /***
55 * Sets the lineNumber.
56 * @param lineNumber The lineNumber to set
57 */
58 public void setLineNumber(int lineNumber) {
59 this.lineNumber = lineNumber;
60 }
61
62 /***
63 * Returns the message.
64 * @return String
65 */
66 public String getMessage() {
67 return message;
68 }
69
70 /***
71 * Returns the rule.
72 * @return Rule
73 */
74 public Rule getRule() {
75 return rule;
76 }
77
78 /***
79 * Sets the message.
80 * @param message The message to set
81 */
82 public void setMessage(String message) {
83 this.message = message;
84 }
85
86 /***
87 * Sets the rule.
88 * @param rule The rule to set
89 */
90 public void setRule(Rule rule) {
91 this.rule = rule;
92 }
93
94 /***
95 * Returns the score.
96 * @return double
97 */
98 public double getScore() {
99 return score;
100 }
101
102 /***
103 * Sets the score.
104 * @param score The score to set
105 */
106 public void setScore(double score) {
107 this.score = score;
108 }
109
110 /***
111 * Sets the score.
112 * @param score The score to set
113 */
114 public void setScore(int score) {
115 this.score = (double) score;
116 }
117
118 }
This page was automatically generated by Maven