Source for org.jfree.data.time.ohlc.OHLC

   1: /* ===========================================================
   2:  * JFreeChart : a free chart library for the Java(tm) platform
   3:  * ===========================================================
   4:  *
   5:  * (C) Copyright 2000-2006, by Object Refinery Limited and Contributors.
   6:  *
   7:  * Project Info:  http://www.jfree.org/jfreechart/index.html
   8:  *
   9:  * This library is free software; you can redistribute it and/or modify it 
  10:  * under the terms of the GNU Lesser General Public License as published by 
  11:  * the Free Software Foundation; either version 2.1 of the License, or 
  12:  * (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but 
  15:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  16:  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
  17:  * License for more details.
  18:  *
  19:  * You should have received a copy of the GNU Lesser General Public
  20:  * License along with this library; if not, write to the Free Software
  21:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
  22:  * USA.  
  23:  *
  24:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  *
  27:  * ---------
  28:  * OHLC.java
  29:  * ---------
  30:  * (C) Copyright 2006, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: OHLC.java,v 1.1.2.1 2006/12/04 17:08:36 mungady Exp $
  36:  *
  37:  * Changes
  38:  * -------
  39:  * 04-Dec-2006 : Version 1 (DG);
  40:  *
  41:  */
  42: 
  43: package org.jfree.data.time.ohlc;
  44: 
  45: import java.io.Serializable;
  46: 
  47: /**
  48:  * A high low data record (immutable).  This class is used internally by the 
  49:  * {@link OHLCItem} class.
  50:  *
  51:  * @since 1.0.4
  52:  */
  53: public class OHLC implements Serializable {
  54:     
  55:     /** The open value. */
  56:     private double open;
  57:     
  58:     /** The close value. */
  59:     private double close;
  60:     
  61:     /** The high value. */
  62:     private double high;
  63:     
  64:     /** The low value. */
  65:     private double low;
  66: 
  67:     /** 
  68:      * Creates a new instance of <code>OHLC</code>.
  69:      *
  70:      * @param open  the open value.
  71:      * @param close  the close value.
  72:      * @param high  the high value.
  73:      * @param low  the low value.
  74:      */
  75:     public OHLC(double open, double high, double low, double close) {
  76:         this.open = open;
  77:         this.close = close;
  78:         this.high = high;
  79:         this.low = low;
  80:     }
  81:     
  82:     /**
  83:      * Returns the open value.
  84:      *
  85:      * @return The open value.
  86:      */
  87:     public double getOpen() {
  88:         return this.open;
  89:     }
  90:     
  91:     /**
  92:      * Returns the close value.
  93:      *
  94:      * @return The close value.
  95:      */
  96:     public double getClose() {
  97:         return this.close;
  98:     }
  99: 
 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: }