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 Comparable<DataPoint> {
    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(DataPoint rhs) {
    33          Double lhsScore = new Double(score);
    34          Double rhsScore = new Double(rhs.getScore());
    35          if (lhsScore.doubleValue() != rhsScore.doubleValue()) {
    36              return lhsScore.compareTo(rhsScore);
    37          }
    38          return random - rhs.random;
    39      }
    40
    41      public SimpleNode getNode() {
    42          return node;
    43      }
    44
    45      public void setNode(SimpleNode 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  }