1 /*** DataPoint.java - part of the MirkE (say murky) application for colormetric analysis emphesizing 2 kinetics. 3 4 Created by: Scott Menor on 21 July, 2004. 5 Last modified by: Scott Menor on 6 November, 2004 6 7 Copyright (c) 2004 Arizona State University - Cancer Research Institute. All rights reserved. 8 9 MirkE is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 MirkE is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with MirkE; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US 22 */ 23 24 package edu.asu.cri.MirkE.dataStructures; 25 26 import java.util.*; 27 28 /*** 29 * A <code>DataPoint</code> represents a single, atomic set of measurements. 30 * It contains a <code>Timestamp</code> (representing when the <code>DataPoint</code>'s 31 * observation took place) and an <code>observableToMeasuredValueMap</code> which maps 32 * from an <code>Observable</code> being measured (or a <code>String</code> name) to an 33 * appropriate class representing the measurement (typically a <code>UnitValue</code> or a <code>MeasuredValue</code>) 34 * 35 * @author Scott Menor 36 */ 37 public class DataPoint { 38 private long id; 39 40 /*** 41 42 @return id 43 */ 44 public long getId() { 45 return id; 46 } 47 48 /*** 49 @param id 50 */ 51 public void setId(long id) { 52 this.id = id; 53 } 54 55 private java.sql.Timestamp timestamp; 56 57 /*** 58 * @deprecated 59 * @return <code>Timestamp</code> for the <code>DataPoint</code> 60 */ 61 public java.sql.Timestamp getTimestamp() { 62 return this.timestamp; 63 } 64 65 /*** 66 * @deprecated 67 * @param timestamp representing when the <code>DataPoint</code> was measured. 68 */ 69 public void setTimestamp(java.sql.Timestamp timestamp) { 70 this.timestamp = timestamp; 71 } 72 73 private Map descriptorMap; 74 75 /*** 76 * @deprecated 77 * @param descriptorMap 78 */ 79 public void setDescriptorMap(Map descriptorMap) { 80 this.descriptorMap = descriptorMap; 81 } 82 83 /*** 84 * @deprecated 85 * @return descriptorMap 86 */ 87 public Map getDescriptorMap() { 88 if (this.descriptorMap == null) { 89 this.descriptorMap = new HashMap(); 90 } 91 92 return this.descriptorMap; 93 } 94 95 private Map observableToMeasuredValueMap; 96 97 /*** 98 * get a <code>Map</code> mapping from <code>Observable</code>s to corresponding <code>MeasuredValue</code>s 99 * 100 * @return observableToMeasuredValueMap 101 */ 102 public Map getObservableToMeasuredValueMap() { 103 if (observableToMeasuredValueMap == null) { 104 observableToMeasuredValueMap = new HashMap(); 105 } 106 107 return observableToMeasuredValueMap; 108 } 109 110 /*** 111 * 112 * @param observable 113 * @return an observation <code>Object</code> (possibly a <code>UnitValue</code>, <code>MeasuredValue</code> or a <code>Number</code>) corresponding to the observable. 114 */ 115 public Object getObservationFromObservable(Object observable) { 116 if (observableToMeasuredValueMap != null) { 117 if (observableToMeasuredValueMap.containsKey(observable)) { 118 return observableToMeasuredValueMap.get(observable); 119 } 120 } 121 122 return null; 123 } 124 125 /*** 126 * 127 * @param observable 128 * @param unitValue corresponding to the observable. 129 */ 130 public void storeUnitValueForObservable(Object observable, UnitValue unitValue) { 131 Map observableToMeasuredValueMap = this.getObservableToMeasuredValueMap(); 132 observableToMeasuredValueMap.put(observable, unitValue); 133 134 } 135 136 /*** 137 * @param observableToMeasuredValueMap 138 */ 139 public void setObservableToMeasuredValueMap(Map observableToMeasuredValueMap) { 140 this.observableToMeasuredValueMap = observableToMeasuredValueMap; 141 } 142 143 /*** 144 * @return string 145 */ 146 public String toString() { 147 if (observableToMeasuredValueMap != null) { 148 149 return "" + timestamp + " " + descriptorMap.toString() + " : " + observableToMeasuredValueMap.toString(); 150 } 151 152 return null; 153 } 154 155 /*** 156 157 @return hashCode 158 */ 159 public int hashCode() { 160 if (observableToMeasuredValueMap != null) { 161 return observableToMeasuredValueMap.hashCode(); 162 } 163 164 return 0; 165 } 166 167 /*** 168 * @param object 169 * @return isEqual 170 */ 171 public boolean equals(Object object) { 172 if (this == object) return true; 173 if (!(object instanceof DataPoint)) return false; 174 175 final DataPoint dataPoint = (DataPoint)object; 176 177 if (!getObservableToMeasuredValueMap().equals(dataPoint.getObservableToMeasuredValueMap())) return false; 178 179 return true; 180 } 181 }