plugins/base1/se.lu.onk/trunk/QPackage/src/qpackage/calculator/Literal.java

Code
Comments
Other
Rev Date Author Line
66 09 Feb 06 enell 1 /*
66 09 Feb 06 enell 2  * Created on 26-May-2004
66 09 Feb 06 enell 3  * 
66 09 Feb 06 enell 4  * Literal.java is a part of WeightedMerge
66 09 Feb 06 enell 5  * Copyright (C) 2004 Johan Enell, Dept Oncology, Lund University
66 09 Feb 06 enell 6  * 
66 09 Feb 06 enell 7  * This program is free software; you can redistribute it and/or modify it under
66 09 Feb 06 enell 8  * the terms of the GNU General Public License as published by the Free Software
66 09 Feb 06 enell 9  * Foundation; either version 2 of the License, or (at your option) any later
66 09 Feb 06 enell 10  * version.
66 09 Feb 06 enell 11  * 
66 09 Feb 06 enell 12  * This program is distributed in the hope that it will be useful, but WITHOUT
66 09 Feb 06 enell 13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
66 09 Feb 06 enell 14  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
66 09 Feb 06 enell 15  * details.
66 09 Feb 06 enell 16  * 
66 09 Feb 06 enell 17  * You should have received a copy of the GNU General Public License along with
66 09 Feb 06 enell 18  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
66 09 Feb 06 enell 19  * Place - Suite 330, Boston, MA 02111-1307, USA.
66 09 Feb 06 enell 20  */
67 10 Feb 06 enell 21 package qpackage.calculator;
66 09 Feb 06 enell 22
66 09 Feb 06 enell 23 import java.util.HashMap;
66 09 Feb 06 enell 24
66 09 Feb 06 enell 25 /**
66 09 Feb 06 enell 26  * A Literal is a constant Operand. It recives it's value when it is constucted
66 09 Feb 06 enell 27  * and it shouldn't be changed after that.
66 09 Feb 06 enell 28  * 
66 09 Feb 06 enell 29  * @author Johan Enell, johan.enell@onk.lu.se, Dept Oncology, Lund University,
66 09 Feb 06 enell 30  *         S-221 85 Lund, Sweden
66 09 Feb 06 enell 31  */
66 09 Feb 06 enell 32 public class Literal extends Operand
66 09 Feb 06 enell 33 {
66 09 Feb 06 enell 34
66 09 Feb 06 enell 35   /**
66 09 Feb 06 enell 36    * Constructs a new Literal with the value set to value.
66 09 Feb 06 enell 37    * 
66 09 Feb 06 enell 38    * @param value
66 09 Feb 06 enell 39    *            the value of the KLiteral.
66 09 Feb 06 enell 40    */
66 09 Feb 06 enell 41   protected Literal(float value)
66 09 Feb 06 enell 42   {
66 09 Feb 06 enell 43     super(value);
66 09 Feb 06 enell 44   }
66 09 Feb 06 enell 45
66 09 Feb 06 enell 46   /**
66 09 Feb 06 enell 47    * Constructs a new Literal with the value set to value using the
66 09 Feb 06 enell 48    * <code>Float.parseFloat(String s)</code> method to parse the value from
66 09 Feb 06 enell 49    * a the string. This method will throw <code>NumberFormatException</code>
66 09 Feb 06 enell 50    * if the string can't be parsed.
66 09 Feb 06 enell 51    * 
66 09 Feb 06 enell 52    * @param value
66 09 Feb 06 enell 53    *            the value of the Literal.
66 09 Feb 06 enell 54    */
66 09 Feb 06 enell 55   protected Literal(String value)
66 09 Feb 06 enell 56   {
66 09 Feb 06 enell 57     super(value);
66 09 Feb 06 enell 58     this.value = Float.parseFloat(value);
66 09 Feb 06 enell 59   }
66 09 Feb 06 enell 60
66 09 Feb 06 enell 61   /*
66 09 Feb 06 enell 62    * (non-Javadoc)
66 09 Feb 06 enell 63    * 
66 09 Feb 06 enell 64    * @see calc.Token#getValue()
66 09 Feb 06 enell 65    */
66 09 Feb 06 enell 66   @Override
66 09 Feb 06 enell 67   protected float getValue()
66 09 Feb 06 enell 68   {
66 09 Feb 06 enell 69     return this.value;
66 09 Feb 06 enell 70   }
66 09 Feb 06 enell 71
66 09 Feb 06 enell 72   /*
66 09 Feb 06 enell 73    * (non-Javadoc)
66 09 Feb 06 enell 74    * 
66 09 Feb 06 enell 75    * @see calc.Token#getValue(java.util.HashMap)
66 09 Feb 06 enell 76    */
66 09 Feb 06 enell 77   @Override
66 09 Feb 06 enell 78   protected float getValue(HashMap variables)
66 09 Feb 06 enell 79   {
66 09 Feb 06 enell 80     return this.value;
66 09 Feb 06 enell 81   }
66 09 Feb 06 enell 82 }