KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/LongProperty.java,v 1.6 2004/02/14 03:34:29 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 /**
25  * @version $Revision: 1.6 $
26  */

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

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

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

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

86     public Object JavaDoc getObjectValue()
87     {
88         return new Long JavaDoc(value);
89     }
90
91     /**
92      * @see java.lang.Object#clone()
93      */

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

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

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

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

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

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