001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.testelement.property;
020:
021: import org.apache.jmeter.testelement.TestElement;
022:
023: /**
024: * @version $Revision: 571988 $
025: */
026: public class FloatProperty extends NumberProperty {
027: float value;
028:
029: float savedValue;
030:
031: public FloatProperty(String name, float value) {
032: super (name);
033: this .value = value;
034: }
035:
036: public FloatProperty() {
037: }
038:
039: /*
040: * (non-Javadoc)
041: *
042: * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
043: */
044: public void setRunningVersion(boolean runningVersion) {
045: savedValue = value;
046: super .setRunningVersion(runningVersion);
047: }
048:
049: /*
050: * (non-Javadoc)
051: *
052: * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
053: */
054: public void recoverRunningVersion(TestElement owner) {
055: value = savedValue;
056: }
057:
058: public void setValue(float value) {
059: this .value = value;
060: }
061:
062: protected void setNumberValue(Number n) {
063: value = n.floatValue();
064: }
065:
066: protected void setNumberValue(String n)
067: throws NumberFormatException {
068: value = Float.parseFloat(n);
069: }
070:
071: /**
072: * @see JMeterProperty#getStringValue()
073: */
074: public String getStringValue() {
075: return Float.toString(value);
076: }
077:
078: /**
079: * @see JMeterProperty#getObjectValue()
080: */
081: public Object getObjectValue() {
082: return new Float(value);
083: }
084:
085: public Object clone() {
086: FloatProperty prop = (FloatProperty) super .clone();
087: prop.value = value;
088: return prop;
089: }
090:
091: /**
092: * @see JMeterProperty#getBooleanValue()
093: */
094: public boolean getBooleanValue() {
095: return value > 0 ? true : false;
096: }
097:
098: /**
099: * @see JMeterProperty#getDoubleValue()
100: */
101: public double getDoubleValue() {
102: return value;
103: }
104:
105: /**
106: * @see JMeterProperty#getFloatValue()
107: */
108: public float getFloatValue() {
109: return value;
110: }
111:
112: /**
113: * @see JMeterProperty#getIntValue()
114: */
115: public int getIntValue() {
116: return (int) value;
117: }
118:
119: /**
120: * @see JMeterProperty#getLongValue()
121: */
122: public long getLongValue() {
123: return (long) value;
124: }
125: }
|