KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/FloatProperty.java,v 1.6 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.6 $
25  */

26 public class FloatProperty extends NumberProperty
27 {
28     float value;
29     float savedValue;
30     
31     public FloatProperty(String JavaDoc name,float value)
32     {
33         super(name);
34         this.value = value;
35     }
36     
37     public FloatProperty()
38     {
39     }
40     
41     /* (non-Javadoc)
42          * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
43          */

44         public void setRunningVersion(boolean runningVersion)
45         {
46             savedValue = value;
47             super.setRunningVersion(runningVersion);
48         }
49
50         /* (non-Javadoc)
51          * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
52          */

53         public void recoverRunningVersion(TestElement owner)
54         {
55             value = savedValue;
56         }
57     
58     public void setValue(float value)
59     {
60         this.value = value;
61     }
62     
63     protected void setNumberValue(Number JavaDoc n)
64     {
65         value = n.floatValue();
66     }
67     
68     protected void setNumberValue(String JavaDoc n) throws NumberFormatException JavaDoc
69     {
70         value = Float.parseFloat(n);
71     }
72
73     /**
74      * @see JMeterProperty#getStringValue()
75      */

76     public String JavaDoc getStringValue()
77     {
78         return Float.toString(value);
79     }
80
81     /**
82      * @see JMeterProperty#getObjectValue()
83      */

84     public Object JavaDoc getObjectValue()
85     {
86         return new Float JavaDoc(value);
87     }
88
89     /**
90      * @see Object#clone()
91      */

92     public Object JavaDoc clone()
93     {
94         FloatProperty prop = (FloatProperty)super.clone();
95         prop.value = value;
96         return prop;
97     }
98
99     /**
100      * @see JMeterProperty#getBooleanValue()
101      */

102     public boolean getBooleanValue()
103     {
104         return value > 0 ? true : false;
105     }
106
107     /**
108      * @see JMeterProperty#getDoubleValue()
109      */

110     public double getDoubleValue()
111     {
112         return (double)value;
113     }
114
115     /**
116      * @see JMeterProperty#getFloatValue()
117      */

118     public float getFloatValue()
119     {
120         return value;
121     }
122
123     /**
124      * @see JMeterProperty#getIntValue()
125      */

126     public int getIntValue()
127     {
128         return (int)value;
129     }
130
131     /**
132      * @see JMeterProperty#getLongValue()
133      */

134     public long getLongValue()
135     {
136         return (long)value;
137     }
138 }
139
Popular Tags