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 net.sourceforge.pmd.ast.SimpleNode;
    7
    8   import java.util.Random;
    9
    10  /***
    11   * @author David Dixon-Peugh
    12   *         Aug 8, 2002 DataPoint.java
    13   */
    14  public class DataPoint implements java.lang.Comparable {
    15
    16      private SimpleNode 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(Object object) {
    33
    34          DataPoint rhs = (DataPoint) object;
    35
    36          Double lhsScore = new Double(score);
    37          Double rhsScore = new Double(rhs.getScore());
    38
    39          if (lhsScore.doubleValue() != rhsScore.doubleValue()) {
    40              return lhsScore.compareTo(rhsScore);
    41          }
    42
    43          Integer lhsRand = new Integer(random);
    44          Integer rhsRand = new Integer(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 getMessage() {
    58          return message;
    59      }
    60
    61      public void setMessage(String 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  }