1 43 44 package org.jfree.data.xy; 45 46 import java.io.Serializable ; 47 import java.util.Date ; 48 49 55 public class OHLCDataItem implements Comparable , Serializable { 56 57 58 private static final long serialVersionUID = 7753817154401169901L; 59 60 61 private Date date; 62 63 64 private Number open; 65 66 67 private Number high; 68 69 70 private Number low; 71 72 73 private Number close; 74 75 76 private Number volume; 77 78 88 public OHLCDataItem(Date date, 89 double open, 90 double high, 91 double low, 92 double close, 93 double volume) { 94 if (date == null) { 95 throw new IllegalArgumentException ("Null 'date' argument."); 96 } 97 this.date = date; 98 this.open = new Double (open); 99 this.high = new Double (high); 100 this.low = new Double (low); 101 this.close = new Double (close); 102 this.volume = new Double (volume); 103 } 104 105 110 public Date getDate() { 111 return this.date; 112 } 113 114 119 public Number getOpen() { 120 return this.open; 121 } 122 123 128 public Number getHigh() { 129 return this.high; 130 } 131 132 137 public Number getLow() { 138 return this.low; 139 } 140 141 146 public Number getClose() { 147 return this.close; 148 } 149 150 155 public Number getVolume() { 156 return this.volume; 157 } 158 159 166 public boolean equals(Object obj) { 167 if (obj == this) { 168 return true; 169 } 170 if (!(obj instanceof OHLCDataItem)) { 171 return false; 172 } 173 OHLCDataItem that = (OHLCDataItem) obj; 174 if (!this.date.equals(that.date)) { 175 return false; 176 } 177 if (!this.high.equals(that.high)) { 178 return false; 179 } 180 if (!this.low.equals(that.low)) { 181 return false; 182 } 183 if (!this.open.equals(that.open)) { 184 return false; 185 } 186 if (!this.close.equals(that.close)) { 187 return false; 188 } 189 return true; 190 } 191 192 202 public int compareTo(Object object) { 203 if (object instanceof OHLCDataItem) { 204 OHLCDataItem item = (OHLCDataItem) object; 205 return this.date.compareTo(item.date); 206 } 207 else { 208 throw new ClassCastException ("OHLCDataItem.compareTo()."); 209 } 210 } 211 212 } 213 | Popular Tags |