KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

49         public void recoverRunningVersion(TestElement owner)
50         {
51             value = savedValue;
52         }
53
54     public IntegerProperty(String JavaDoc name)
55     {
56         super(name);
57     }
58
59     public IntegerProperty()
60     {
61         super();
62     }
63
64     public void setValue(int value)
65     {
66         this.value = value;
67     }
68
69     protected void setNumberValue(Number JavaDoc n)
70     {
71         value = n.intValue();
72     }
73
74     protected void setNumberValue(String JavaDoc n) throws NumberFormatException JavaDoc
75     {
76         value = Integer.parseInt(n);
77     }
78
79     /**
80      * @see JMeterProperty#getStringValue()
81      */

82     public String JavaDoc getStringValue()
83     {
84         return Integer.toString(value);
85     }
86
87     /**
88      * @see JMeterProperty#getObjectValue()
89      */

90     public Object JavaDoc getObjectValue()
91     {
92         return new Integer JavaDoc(value);
93     }
94
95     /**
96      * @see Object#clone()
97      */

98     public Object JavaDoc clone()
99     {
100         IntegerProperty prop = (IntegerProperty) super.clone();
101         prop.value = value;
102         return prop;
103     }
104
105     /**
106      * @see JMeterProperty#getBooleanValue()
107      */

108     public boolean getBooleanValue()
109     {
110         return getIntValue() > 0 ? true : false;
111     }
112
113     /**
114      * @see JMeterProperty#getDoubleValue()
115      */

116     public double getDoubleValue()
117     {
118         return (double) value;
119     }
120
121     /**
122      * @see JMeterProperty#getFloatValue()
123      */

124     public float getFloatValue()
125     {
126         return (float) value;
127     }
128
129     /**
130      * @see JMeterProperty#getIntValue()
131      */

132     public int getIntValue()
133     {
134         return value;
135     }
136
137     /**
138      * @see JMeterProperty#getLongValue()
139      */

140     public long getLongValue()
141     {
142         return (long) value;
143     }
144 }
145
Popular Tags