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 DoubleProperty extends NumberProperty {
027: double value;
028:
029: double savedValue;
030:
031: public DoubleProperty(String name, double value) {
032: super (name);
033: this .value = value;
034: }
035:
036: public DoubleProperty() {
037: }
038:
039: public void setValue(float value) {
040: this .value = value;
041: }
042:
043: protected void setNumberValue(Number n) {
044: value = n.doubleValue();
045: }
046:
047: protected void setNumberValue(String n)
048: throws NumberFormatException {
049: value = Double.parseDouble(n);
050: }
051:
052: /**
053: * @see JMeterProperty#getStringValue()
054: */
055: public String getStringValue() {
056: return Double.toString(value);
057: }
058:
059: /**
060: * @see JMeterProperty#getObjectValue()
061: */
062: public Object getObjectValue() {
063: return new Double(value);
064: }
065:
066: public Object clone() {
067: DoubleProperty prop = (DoubleProperty) super .clone();
068: prop.value = value;
069: return prop;
070: }
071:
072: /**
073: * @see JMeterProperty#getBooleanValue()
074: */
075: public boolean getBooleanValue() {
076: return value > 0 ? true : false;
077: }
078:
079: /**
080: * @see JMeterProperty#getDoubleValue()
081: */
082: public double getDoubleValue() {
083: return value;
084: }
085:
086: /**
087: * @see JMeterProperty#getFloatValue()
088: */
089: public float getFloatValue() {
090: return (float) value;
091: }
092:
093: /**
094: * @see JMeterProperty#getIntValue()
095: */
096: public int getIntValue() {
097: return (int) value;
098: }
099:
100: /**
101: * @see JMeterProperty#getLongValue()
102: */
103: public long getLongValue() {
104: return (long) value;
105: }
106:
107: /*
108: * (non-Javadoc)
109: *
110: * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
111: */
112: public void setRunningVersion(boolean runningVersion) {
113: savedValue = value;
114: super .setRunningVersion(runningVersion);
115: }
116:
117: /*
118: * (non-Javadoc)
119: *
120: * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
121: */
122: public void recoverRunningVersion(TestElement owner) {
123: value = savedValue;
124: }
125: }
|