KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > testelement > property > DoubleProperty


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/DoubleProperty.java,v 1.5 2004/02/13 02:21:38 sebb 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.5 $
25  */

26 public class DoubleProperty extends NumberProperty
27 {
28     double value;
29     double savedValue;
30     
31     public DoubleProperty(String JavaDoc name,double value)
32     {
33         super(name);
34         this.value = value;
35     }
36     
37     public DoubleProperty()
38     {
39     }
40     
41     public void setValue(float value)
42     {
43         this.value = value;
44     }
45     
46     protected void setNumberValue(Number JavaDoc n)
47     {
48         value = n.doubleValue();
49     }
50
51     protected void setNumberValue(String JavaDoc n) throws NumberFormatException JavaDoc
52     {
53         value = Double.parseDouble(n);
54     }
55
56     /**
57      * @see JMeterProperty#getStringValue()
58      */

59     public String JavaDoc getStringValue()
60     {
61         return Double.toString(value);
62     }
63
64     /**
65      * @see JMeterProperty#getObjectValue()
66      */

67     public Object JavaDoc getObjectValue()
68     {
69         return new Double JavaDoc(value);
70     }
71
72     /**
73      * @see Object#clone()
74      */

75     public Object JavaDoc clone()
76     {
77         DoubleProperty prop = (DoubleProperty)super.clone();
78         prop.value = value;
79         return prop;
80     }
81
82     /**
83      * @see JMeterProperty#getBooleanValue()
84      */

85     public boolean getBooleanValue()
86     {
87         return value > 0 ? true : false;
88     }
89
90     /**
91      * @see JMeterProperty#getDoubleValue()
92      */

93     public double getDoubleValue()
94     {
95         return value;
96     }
97
98     /**
99      * @see JMeterProperty#getFloatValue()
100      */

101     public float getFloatValue()
102     {
103         return (float)value;
104     }
105
106     /**
107      * @see JMeterProperty#getIntValue()
108      */

109     public int getIntValue()
110     {
111         return (int)value;
112     }
113
114     /**
115      * @see JMeterProperty#getLongValue()
116      */

117     public long getLongValue()
118     {
119         return (long)value;
120     }
121     
122     /* (non-Javadoc)
123          * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
124          */

125         public void setRunningVersion(boolean runningVersion)
126         {
127             savedValue = value;
128             super.setRunningVersion(runningVersion);
129         }
130
131         /* (non-Javadoc)
132          * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
133          */

134         public void recoverRunningVersion(TestElement owner)
135         {
136             value = savedValue;
137         }
138 }
139
Popular Tags