001 /* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-2006, 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 * $Id: OHLC.java,v 1.1.2.1 2006/12/04 17:08:36 mungady Exp $
036 *
037 * Changes
038 * -------
039 * 04-Dec-2006 : Version 1 (DG);
040 *
041 */
042
043 package org.jfree.data.time.ohlc;
044
045 import java.io.Serializable;
046
047 /**
048 * A high low data record (immutable). This class is used internally by the
049 * {@link OHLCItem} class.
050 *
051 * @since 1.0.4
052 */
053 public class OHLC implements Serializable {
054
055 /** The open value. */
056 private double open;
057
058 /** The close value. */
059 private double close;
060
061 /** The high value. */
062 private double high;
063
064 /** The low value. */
065 private double low;
066
067 /**
068 * Creates a new instance of <code>OHLC</code>.
069 *
070 * @param open the open value.
071 * @param close the close value.
072 * @param high the high value.
073 * @param low the low value.
074 */
075 public OHLC(double open, double high, double low, double close) {
076 this.open = open;
077 this.close = close;
078 this.high = high;
079 this.low = low;
080 }
081
082 /**
083 * Returns the open value.
084 *
085 * @return The open value.
086 */
087 public double getOpen() {
088 return this.open;
089 }
090
091 /**
092 * Returns the close value.
093 *
094 * @return The close value.
095 */
096 public double getClose() {
097 return this.close;
098 }
099
100 /**
101 * Returns the high value.
102 *
103 * @return The high value.
104 */
105 public double getHigh() {
106 return this.high;
107 }
108
109 /**
110 * Returns the low value.
111 *
112 * @return The low value.
113 */
114 public double getLow() {
115 return this.low;
116 }
117
118 /**
119 * Tests this instance for equality with an arbitrary object.
120 *
121 * @param obj the object (<code>null</code> permitted).
122 *
123 * @return A boolean.
124 */
125 public boolean equals(Object obj) {
126 if (obj == this) {
127 return true;
128 }
129 if (!(obj instanceof OHLC)) {
130 return false;
131 }
132 OHLC that = (OHLC) obj;
133 if (this.open != that.open) {
134 return false;
135 }
136 if (this.close != that.close) {
137 return false;
138 }
139 if (this.high != that.high) {
140 return false;
141 }
142 if (this.low != that.low) {
143 return false;
144 }
145 return true;
146 }
147
148 }