KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > stat > DataPoint


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package net.sourceforge.pmd.stat;
5
6 import net.sourceforge.pmd.ast.SimpleNode;
7
8 import java.util.Random JavaDoc;
9
10 /**
11  * @author David Dixon-Peugh
12  * Aug 8, 2002 DataPoint.java
13  */

14 public class DataPoint implements java.lang.Comparable JavaDoc {
15
16     private SimpleNode node;
17     private int random;
18     private double score;
19     private String JavaDoc 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 JavaDoc rand = new Random JavaDoc();
29         random = rand.nextInt(11061973);
30     }
31
32     public int compareTo(Object JavaDoc object) {
33
34         DataPoint rhs = (DataPoint) object;
35
36         Double JavaDoc lhsScore = new Double JavaDoc(score);
37         Double JavaDoc rhsScore = new Double JavaDoc(rhs.getScore());
38
39         if (lhsScore.doubleValue() != rhsScore.doubleValue()) {
40             return lhsScore.compareTo(rhsScore);
41         }
42
43         Integer JavaDoc lhsRand = new Integer JavaDoc(random);
44         Integer JavaDoc rhsRand = new Integer JavaDoc(rhs.random);
45
46         return lhsRand.compareTo(rhsRand);
47     }
48
49     public SimpleNode getNode() {
50         return node;
51     }
52
53     public void setNode(SimpleNode node) {
54         this.node = node;
55     }
56
57     public String JavaDoc getMessage() {
58         return message;
59     }
60
61     public void setMessage(String JavaDoc message) {
62         this.message = message;
63     }
64
65     public double getScore() {
66         return score;
67     }
68
69     public void setScore(double score) {
70         this.score = score;
71     }
72 }
73
Popular Tags