KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/MultiProperty.java,v 1.8 2004/02/13 02:40:53 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  * For JMeterProperties that hold multiple properties within, provides a simple
25  * interface for retrieving a property iterator for the sub values.
26  *
27  * @version $Revision: 1.8 $
28  */

29 public abstract class MultiProperty extends AbstractProperty
30 {
31     public MultiProperty()
32     {
33         super();
34     }
35
36     public MultiProperty(String JavaDoc name)
37     {
38         super(name);
39     }
40     
41     /**
42      * Get the property iterator to iterate through the sub-values of this
43      * JMeterProperty.
44      *
45      * @return an iterator for the sub-values of this property
46      */

47     public abstract PropertyIterator iterator();
48     
49     /**
50      * Add a property to the collection.
51      */

52     public abstract void addProperty(JMeterProperty prop);
53     
54     /**
55      * Clear away all values in the property.
56      */

57     public abstract void clear();
58
59
60     public void setRunningVersion(boolean running)
61     {
62         super.setRunningVersion(running);
63         PropertyIterator iter = iterator();
64         while (iter.hasNext())
65         {
66             iter.next().setRunningVersion(running);
67         }
68     }
69
70     protected void recoverRunningVersionOfSubElements(TestElement owner)
71     {
72         PropertyIterator iter = iterator();
73         while (iter.hasNext())
74         {
75             JMeterProperty prop = iter.next();
76             if (owner.isTemporary(prop))
77             {
78                 iter.remove();
79             }
80             else
81             {
82                 prop.recoverRunningVersion(owner);
83             }
84         }
85     }
86
87     public void mergeIn(JMeterProperty prop)
88     {
89         if (prop.getObjectValue() == getObjectValue())
90         {
91             return;
92         }
93         log.debug("merging in " + prop.getClass());
94         if (prop instanceof MultiProperty)
95         {
96             PropertyIterator iter = ((MultiProperty) prop).iterator();
97             while (iter.hasNext())
98             {
99                 JMeterProperty item = iter.next();
100                 addProperty(item);
101             }
102         }
103         else
104         {
105             addProperty(prop);
106         }
107     }
108 }
109
Popular Tags