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-2007, 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:  * Changes
  36:  * -------
  37:  * 04-Dec-2006 : Version 1 (DG);
  38:  *
  39:  */
  40: 
  41: package org.jfree.data.time.ohlc;
  42: 
  43: import java.io.Serializable;
  44: 
  45: /**
  46:  * A high low data record (immutable).  This class is used internally by the 
  47:  * {@link OHLCItem} class.
  48:  *
  49:  * @since 1.0.4
  50:  */
  51: public class OHLC implements Serializable {
  52:     
  53:     /** The open value. */
  54:     private double open;
  55:     
  56:     /** The close value. */
  57:     private double close;
  58:     
  59:     /** The high value. */
  60:     private double high;
  61:     
  62:     /** The low value. */
  63:     private double low;
  64: 
  65:     /** 
  66:      * Creates a new instance of <code>OHLC</code>.
  67:      *
  68:      * @param open  the open value.
  69:      * @param close  the close value.
  70:      * @param high  the high value.
  71:      * @param low  the low value.
  72:      */
  73:     public OHLC(double open, double high, double low, double close) {
  74:         this.open = open;
  75:         this.close = close;
  76:         this.high = high;
  77:         this.low = low;
  78:     }
  79:     
  80:     /**
  81:      * Returns the open value.
  82:      *
  83:      * @return The open value.
  84:      */
  85:     public double getOpen() {
  86:         return this.open;
  87:     }
  88:     
  89:     /**
  90:      * Returns the close value.
  91:      *
  92:      * @return The close value.
  93:      */
  94:     public double getClose() {
  95:         return this.close;
  96:     }
  97: 
  98:     /**
  99:      * 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: }