001: package org.acm.seguin.pmd.stat;
002:
003: import org.acm.seguin.pmd.Rule;
004:
005: import java.util.Random;
006:
007: /**
008: * @author David Dixon-Peugh
009: * Aug 8, 2002 DataPoint.java
010: */
011: public class DataPoint implements java.lang.Comparable {
012: private int lineNumber;
013: private int random;
014: private double score;
015: private String message;
016: private Rule rule;
017:
018: /**
019: * Constructor for DataPoint.
020: */
021: public DataPoint() {
022: super ();
023: // Random number is so that the TreeSet doesn't
024: // whack things with the same score.
025: Random rand = new Random();
026: random = rand.nextInt(11061973);
027: }
028:
029: public int compareTo(Object object) {
030:
031: DataPoint rhs = (DataPoint) object;
032:
033: Double lhsScore = new Double(score);
034: Double rhsScore = new Double(rhs.getScore());
035:
036: if (lhsScore.doubleValue() != rhsScore.doubleValue()) {
037: return lhsScore.compareTo(rhsScore);
038: }
039:
040: Integer lhsRand = new Integer(random);
041: Integer rhsRand = new Integer(rhs.random);
042:
043: return lhsRand.compareTo(rhsRand);
044: }
045:
046: /**
047: * Returns the lineNumber.
048: * @return int
049: */
050: public int getLineNumber() {
051: return lineNumber;
052: }
053:
054: /**
055: * Sets the lineNumber.
056: * @param lineNumber The lineNumber to set
057: */
058: public void setLineNumber(int lineNumber) {
059: this .lineNumber = lineNumber;
060: }
061:
062: /**
063: * Returns the message.
064: * @return String
065: */
066: public String getMessage() {
067: return message;
068: }
069:
070: /**
071: * Returns the rule.
072: * @return Rule
073: */
074: public Rule getRule() {
075: return rule;
076: }
077:
078: /**
079: * Sets the message.
080: * @param message The message to set
081: */
082: public void setMessage(String message) {
083: this .message = message;
084: }
085:
086: /**
087: * Sets the rule.
088: * @param rule The rule to set
089: */
090: public void setRule(Rule rule) {
091: this .rule = rule;
092: }
093:
094: /**
095: * Returns the score.
096: * @return double
097: */
098: public double getScore() {
099: return score;
100: }
101:
102: /**
103: * Sets the score.
104: * @param score The score to set
105: */
106: public void setScore(double score) {
107: this .score = score;
108: }
109:
110: /**
111: * Sets the score.
112: * @param score The score to set
113: */
114: public void setScore(int score) {
115: this .score = (double) score;
116: }
117:
118: }
|