KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/TestElementProperty.java,v 1.15 2004/02/21 21:59:37 sebb Exp $
2
/*
3  * Copyright 2001-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.15 $
25  */

26 public class TestElementProperty extends MultiProperty
27 {
28     TestElement value;
29     TestElement savedValue = null;
30
31     public TestElementProperty(String JavaDoc name, TestElement value)
32     {
33         super(name);
34         this.value = value;
35     }
36
37     public TestElementProperty()
38     {
39         super();
40     }
41
42     /**
43      * Determines if two test elements are equal.
44      *
45      * @return true if the value is not null and equals the other Objects value;
46      * false otherwise (even if both values are null)
47      */

48     public boolean equals(Object JavaDoc o)
49     {
50         if (o instanceof TestElementProperty)
51         {
52             if (this == o) return true;
53             if (value != null)
54             {
55                 return value.equals(((JMeterProperty) o).getObjectValue());
56             }
57         }
58         return false;
59     }
60     public int hashCode()
61     {
62         return value == null ? 0 : value.hashCode();
63     }
64
65     /* (non-Javadoc)
66      * #getStringValue()
67      */

68     public String JavaDoc getStringValue()
69     {
70         return value.toString();
71     }
72
73     public void setObjectValue(Object JavaDoc v)
74     {
75         if (v instanceof TestElement)
76         {
77             value = (TestElement) v;
78         }
79     }
80
81     /* (non-Javadoc)
82      * #getObjectValue()
83      */

84     public Object JavaDoc getObjectValue()
85     {
86         return value;
87     }
88
89     public TestElement getElement()
90     {
91         return value;
92     }
93
94     public void setElement(TestElement el)
95     {
96         value = el;
97     }
98
99     /* (non-Javadoc)
100      * @see java.lang.Object#clone()
101      */

102     public Object JavaDoc clone()
103     {
104         TestElementProperty prop = (TestElementProperty) super.clone();
105         prop.value = (TestElement) value.clone();
106         return prop;
107     }
108
109     /* (non-Javadoc)
110      * #mergeIn(JMeterProperty)
111      */

112     public void mergeIn(JMeterProperty prop)
113     {
114         if (isEqualType(prop))
115         {
116             value.addTestElement((TestElement) prop.getObjectValue());
117         }
118     }
119
120     /* (non-Javadoc)
121      * #recoverRunningVersion(TestElement)
122      */

123     public void recoverRunningVersion(TestElement owner)
124     {
125         if (savedValue != null)
126         {
127             value = savedValue;
128         }
129         value.recoverRunningVersion();
130     }
131
132     /* (non-Javadoc)
133      * #setRunningVersion(boolean)
134      */

135     public void setRunningVersion(boolean runningVersion)
136     {
137         super.setRunningVersion(runningVersion);
138         value.setRunningVersion(runningVersion);
139         if(runningVersion)
140         {
141             savedValue = value;
142         }
143         else
144         {
145             savedValue = null;
146         }
147     }
148
149     /* (non-Javadoc)
150      * @see MultiProperty#addProperty(JMeterProperty)
151      */

152     public void addProperty(JMeterProperty prop)
153     {
154         value.setProperty(prop);
155     }
156
157     /* (non-Javadoc)
158      * @see MultiProperty#clear()
159      */

160     public void clear()
161     {
162         value.clear();
163
164     }
165
166     /* (non-Javadoc)
167      * @see MultiProperty#iterator()
168      */

169     public PropertyIterator iterator()
170     {
171         return value.propertyIterator();
172     }
173 }
174
Popular Tags