01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package net.sourceforge.pmd.stat;
04:
05: import net.sourceforge.pmd.ast.SimpleNode;
06:
07: import java.util.Random;
08:
09: /**
10: * @author David Dixon-Peugh
11: * Aug 8, 2002 DataPoint.java
12: */
13: public class DataPoint implements Comparable<DataPoint> {
14:
15: private SimpleNode node;
16: private int random;
17: private double score;
18: private String message;
19:
20: /**
21: * Constructor for DataPoint.
22: */
23: public DataPoint() {
24: super ();
25: // Random number is so that the TreeSet doesn't
26: // whack things with the same score.
27: Random rand = new Random();
28: random = rand.nextInt(11061973);
29: }
30:
31: public int compareTo(DataPoint rhs) {
32: Double lhsScore = new Double(score);
33: Double rhsScore = new Double(rhs.getScore());
34: if (lhsScore.doubleValue() != rhsScore.doubleValue()) {
35: return lhsScore.compareTo(rhsScore);
36: }
37: return random - rhs.random;
38: }
39:
40: public SimpleNode getNode() {
41: return node;
42: }
43:
44: public void setNode(SimpleNode node) {
45: this .node = node;
46: }
47:
48: public String getMessage() {
49: return message;
50: }
51:
52: public void setMessage(String message) {
53: this .message = message;
54: }
55:
56: public double getScore() {
57: return score;
58: }
59:
60: public void setScore(double score) {
61: this.score = score;
62: }
63: }
|