01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: 493779 $
28: */
29: public abstract class MultiProperty extends AbstractProperty {
30: public MultiProperty() {
31: super ();
32: }
33:
34: public MultiProperty(String name) {
35: super (name);
36: }
37:
38: /**
39: * Get the property iterator to iterate through the sub-values of this
40: * JMeterProperty.
41: *
42: * @return an iterator for the sub-values of this property
43: */
44: public abstract PropertyIterator iterator();
45:
46: /**
47: * Add a property to the collection.
48: */
49: public abstract void addProperty(JMeterProperty prop);
50:
51: /**
52: * Clear away all values in the property.
53: */
54: public abstract void clear();
55:
56: public void setRunningVersion(boolean running) {
57: super .setRunningVersion(running);
58: PropertyIterator iter = iterator();
59: while (iter.hasNext()) {
60: iter.next().setRunningVersion(running);
61: }
62: }
63:
64: protected void recoverRunningVersionOfSubElements(TestElement owner) {
65: PropertyIterator iter = iterator();
66: while (iter.hasNext()) {
67: JMeterProperty prop = iter.next();
68: if (owner.isTemporary(prop)) {
69: iter.remove();
70: } else {
71: prop.recoverRunningVersion(owner);
72: }
73: }
74: }
75:
76: public void mergeIn(JMeterProperty prop) {
77: if (prop.getObjectValue() == getObjectValue()) {
78: return;
79: }
80: log.debug("merging in " + prop.getClass());
81: if (prop instanceof MultiProperty) {
82: PropertyIterator iter = ((MultiProperty) prop).iterator();
83: while (iter.hasNext()) {
84: JMeterProperty item = iter.next();
85: addProperty(item);
86: }
87: } else {
88: addProperty(prop);
89: }
90: }
91: }
|