KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/BooleanProperty.java,v 1.9 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 import org.apache.jorphan.util.JOrphanUtils;
23
24 /**
25  * @version $Revision: 1.9 $
26  */

27 public class BooleanProperty extends AbstractProperty
28 {
29     boolean value; //TODO: should these be private?
30
boolean savedValue;
31     
32     public BooleanProperty(String JavaDoc name,boolean v)
33     {
34         super(name);
35         value = v;
36     }
37     
38     public BooleanProperty()
39     {
40         super();
41     }
42     
43     public void setObjectValue(Object JavaDoc v)
44     {
45         if(v instanceof Boolean JavaDoc)
46         {
47             value = ((Boolean JavaDoc)v).booleanValue();
48         }
49         else
50         {
51             value = Boolean.valueOf(v.toString()).booleanValue();
52         }
53     }
54
55     /**
56      * @see JMeterProperty#getStringValue()
57      */

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

66     public Object JavaDoc getObjectValue()
67     {
68         return JOrphanUtils.valueOf(value);
69     }
70
71     /**
72      * @see Object#clone()
73      */

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

84     public boolean getBooleanValue()
85     {
86         return value;
87     }
88     /* (non-Javadoc)
89      * @see org.apache.jmeter.testelement.property.JMeterProperty#setRunningVersion(boolean)
90      */

91     public void setRunningVersion(boolean runningVersion)
92     {
93         savedValue = value;
94         super.setRunningVersion(runningVersion);
95     }
96
97     /* (non-Javadoc)
98      * @see org.apache.jmeter.testelement.property.JMeterProperty#recoverRunningVersion(org.apache.jmeter.testelement.TestElement)
99      */

100     public void recoverRunningVersion(TestElement owner)
101     {
102         value = savedValue;
103     }
104
105 }
106
Popular Tags