View Javadoc

1   /*
2    * The contents of this file are subject to the terms 
3    * of the Common Development and Distribution License 
4    * (the "License").  You may not use this file except 
5    * in compliance with the License.
6    * 
7    * You can obtain a copy of the license at 
8    * http://www.sun.com/cddl/cddl.html. 
9    * See the License for the specific language governing 
10   * permissions and limitations under the License.
11   * 
12   * When distributing Covered Code, include this CDDL 
13   * HEADER in each file and include the License file at 
14   * license.txt.  If applicable, add the following below 
15   * this CDDL HEADER, with the fields enclosed by brackets 
16   * "[]" replaced with your own identifying information: 
17   * Portions Copyright [yyyy] [name of copyright owner]
18   * 
19   * Portions Copyright 2004 eBay, Inc.
20   */
21  package com.ebay.carad.os.vitalsigns;
22  
23  import org.apache.commons.lang.builder.EqualsBuilder;
24  import org.apache.commons.lang.builder.HashCodeBuilder;
25  import org.apache.commons.lang.builder.ToStringBuilder;
26  
27  /***
28   * <p>A point of data logged at a given time, which represents the meat of most standard
29   * "data in timeline" type reports.</p>
30   *
31   * <p>Sorts itself in order of logtime ascending.</p>
32   * 
33   * @author Jeremy Thomerson
34   * @version $Id$
35   */
36  public class DataPoint implements Comparable {
37  
38      //private static final Logger LOGGER = Logger.getLogger(DataPoint.class);
39  
40      private long mLogTime;
41      private float mData;
42      
43      public DataPoint() {
44          super();
45      }
46  
47      public DataPoint(long logTime, float data) {
48          this();
49          setLogTime(logTime);
50          setData(data);
51      }
52  
53      public float getData() {
54          return mData;
55      }
56  
57      public void setData(float data) {
58          mData = data;
59      }
60  
61      public long getLogTime() {
62          return mLogTime;
63      }
64  
65      public void setLogTime(long logTime) {
66          mLogTime = logTime;
67      }
68  
69      /***
70       * Sorts itself in order of logtime ascending.
71       * @param other the other Object to compare self to.
72       * @return see interface
73       */
74      public int compareTo(Object other) {
75      	return (int) (mLogTime - ((DataPoint) other).mLogTime);
76      }
77      
78      public String toString() {
79      	return new ToStringBuilder(this)
80      		.append("mLogTime", mLogTime)
81      		.append("mData", mData)
82      		.toString();
83      }
84      public boolean equals(Object other) {
85      	if (!(other instanceof DataPoint)) {
86      		return false;
87      	}
88      	DataPoint rhs = (DataPoint) other;
89      	return new EqualsBuilder()
90      		.append(getData(), rhs.getData())
91      		.append(getLogTime(), rhs.getLogTime())
92      		.isEquals();
93      }
94      public int hashCode() {
95      	return new HashCodeBuilder()
96      		.append(getData())
97      		.append(getLogTime())
98      		.toHashCode();
99      }
100 }
101