Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.testelement.property » [javadoc | source]
    1   // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/FloatProperty.java,v 1.8 2005/07/12 20:50:25 mstover1 Exp $
    2   /*
    3    * Copyright 2003-2004 The Apache Software Foundation.
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    *   http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    * 
   17    */
   18   
   19   package org.apache.jmeter.testelement.property;
   20   
   21   import org.apache.jmeter.testelement.TestElement;
   22   
   23   /**
   24    * @version $Revision: 1.8 $
   25    */
   26   public class FloatProperty extends NumberProperty {
   27   	float value;
   28   
   29   	float savedValue;
   30   
   31   	public FloatProperty(String name, float value) {
   32   		super(name);
   33   		this.value = value;
   34   	}
   35   
   36   	public FloatProperty() {
   37   	}
   38   
   39   	/*
   40   	 * (non-Javadoc)
   41   	 * 
   42   	 * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
   43   	 */
   44   	public void setRunningVersion(boolean runningVersion) {
   45   		savedValue = value;
   46   		super.setRunningVersion(runningVersion);
   47   	}
   48   
   49   	/*
   50   	 * (non-Javadoc)
   51   	 * 
   52   	 * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
   53   	 */
   54   	public void recoverRunningVersion(TestElement owner) {
   55   		value = savedValue;
   56   	}
   57   
   58   	public void setValue(float value) {
   59   		this.value = value;
   60   	}
   61   
   62   	protected void setNumberValue(Number n) {
   63   		value = n.floatValue();
   64   	}
   65   
   66   	protected void setNumberValue(String n) throws NumberFormatException {
   67   		value = Float.parseFloat(n);
   68   	}
   69   
   70   	/**
   71   	 * @see JMeterProperty#getStringValue()
   72   	 */
   73   	public String getStringValue() {
   74   		return Float.toString(value);
   75   	}
   76   
   77   	/**
   78   	 * @see JMeterProperty#getObjectValue()
   79   	 */
   80   	public Object getObjectValue() {
   81   		return new Float(value);
   82   	}
   83   
   84   	/**
   85   	 * @see Object#clone()
   86   	 */
   87   	public Object clone() {
   88   		FloatProperty prop = (FloatProperty) super.clone();
   89   		prop.value = value;
   90   		return prop;
   91   	}
   92   
   93   	/**
   94   	 * @see JMeterProperty#getBooleanValue()
   95   	 */
   96   	public boolean getBooleanValue() {
   97   		return value > 0 ? true : false;
   98   	}
   99   
  100   	/**
  101   	 * @see JMeterProperty#getDoubleValue()
  102   	 */
  103   	public double getDoubleValue() {
  104   		return value;
  105   	}
  106   
  107   	/**
  108   	 * @see JMeterProperty#getFloatValue()
  109   	 */
  110   	public float getFloatValue() {
  111   		return value;
  112   	}
  113   
  114   	/**
  115   	 * @see JMeterProperty#getIntValue()
  116   	 */
  117   	public int getIntValue() {
  118   		return (int) value;
  119   	}
  120   
  121   	/**
  122   	 * @see JMeterProperty#getLongValue()
  123   	 */
  124   	public long getLongValue() {
  125   		return (long) value;
  126   	}
  127   }

Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.testelement.property » [javadoc | source]