View Javadoc

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 java.util.Random;
7   
8   /***
9    * @author David Dixon-Peugh
10   *         Aug 8, 2002 DataPoint.java
11   */
12  public class DataPoint implements java.lang.Comparable {
13      private int lineNumber;
14      private int random;
15      private double score;
16      private String message;
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      public int getLineNumber() {
47          return lineNumber;
48      }
49  
50      public void setLineNumber(int lineNumber) {
51          this.lineNumber = lineNumber;
52      }
53  
54      public String getMessage() {
55          return message;
56      }
57  
58      public void setMessage(String message) {
59          this.message = message;
60      }
61  
62      public double getScore() {
63          return score;
64      }
65  
66      public void setScore(double score) {
67          this.score = score;
68      }
69  }