Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.testelement.property » [javadoc | source]
    1   // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/property/MultiProperty.java,v 1.9 2005/07/12 20:50:25 mstover1 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.9 $
   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   }

Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.testelement.property » [javadoc | source]