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