001 /* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors.
006 *
007 * Project Info: http://www.jfree.org/jfreechart/index.html
008 *
009 * This library is free software; you can redistribute it and/or modify it
010 * under the terms of the GNU Lesser General Public License as published by
011 * the Free Software Foundation; either version 2.1 of the License, or
012 * (at your option) any later version.
013 *
014 * This library is distributed in the hope that it will be useful, but
015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017 * License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this library; if not, write to the Free Software
021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022 * USA.
023 *
024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025 * in the United States and other countries.]
026 *
027 * ---------
028 * OHLC.java
029 * ---------
030 * (C) Copyright 2006, by Object Refinery Limited.
031 *
032 * Original Author: David Gilbert (for Object Refinery Limited);
033 * Contributor(s): -;
034 *
035 * Changes
036 * -------
037 * 04-Dec-2006 : Version 1 (DG);
038 *
039 */
040
041 package org.jfree.data.time.ohlc;
042
043 import java.io.Serializable;
044
045 /**
046 * A high low data record (immutable). This class is used internally by the
047 * {@link OHLCItem} class.
048 *
049 * @since 1.0.4
050 */
051 public class OHLC implements Serializable {
052
053 /** The open value. */
054 private double open;
055
056 /** The close value. */
057 private double close;
058
059 /** The high value. */
060 private double high;
061
062 /** The low value. */
063 private double low;
064
065 /**
066 * Creates a new instance of <code>OHLC</code>.
067 *
068 * @param open the open value.
069 * @param close the close value.
070 * @param high the high value.
071 * @param low the low value.
072 */
073 public OHLC(double open, double high, double low, double close) {
074 this.open = open;
075 this.close = close;
076 this.high = high;
077 this.low = low;
078 }
079
080 /**
081 * Returns the open value.
082 *
083 * @return The open value.
084 */
085 public double getOpen() {
086 return this.open;
087 }
088
089 /**
090 * Returns the close value.
091 *
092 * @return The close value.
093 */
094 public double getClose() {
095 return this.close;
096 }
097
098 /**
099 * Returns the high value.
100 *
101 * @return The high value.
102 */
103 public double getHigh() {
104 return this.high;
105 }
106
107 /**
108 * Returns the low value.
109 *
110 * @return The low value.
111 */
112 public double getLow() {
113 return this.low;
114 }
115
116 /**
117 * Tests this instance for equality with an arbitrary object.
118 *
119 * @param obj the object (<code>null</code> permitted).
120 *
121 * @return A boolean.
122 */
123 public boolean equals(Object obj) {
124 if (obj == this) {
125 return true;
126 }
127 if (!(obj instanceof OHLC)) {
128 return false;
129 }
130 OHLC that = (OHLC) obj;
131 if (this.open != that.open) {
132 return false;
133 }
134 if (this.close != that.close) {
135 return false;
136 }
137 if (this.high != that.high) {
138 return false;
139 }
140 if (this.low != that.low) {
141 return false;
142 }
143 return true;
144 }
145
146 }