1 18 19 22 package org.apache.jmeter.engine.util; 23 24 import java.util.Iterator ; 25 import java.util.Map ; 26 27 import org.apache.jmeter.functions.InvalidVariableException; 28 import org.apache.jmeter.testelement.property.JMeterProperty; 29 import org.apache.jmeter.testelement.property.StringProperty; 30 import org.apache.jmeter.util.StringUtilities; 31 32 36 public class ReplaceFunctionsWithStrings extends AbstractTransformer 37 { 38 public ReplaceFunctionsWithStrings( 39 CompoundVariable masterFunction, 40 Map variables) 41 { 42 super(); 43 setMasterFunction(masterFunction); 44 setVariables(variables); 45 } 46 47 50 public JMeterProperty transformValue(JMeterProperty prop) 51 throws InvalidVariableException 52 { 53 Iterator iter = getVariables().keySet().iterator(); 54 String input = prop.getStringValue(); 55 while (iter.hasNext()) 56 { 57 String key = (String ) iter.next(); 58 String value = (String ) getVariables().get(key); 59 input = StringUtilities.substitute(input, value, "${" + key + "}"); 60 } 61 StringProperty newProp = new StringProperty(prop.getName(), input); 62 return newProp; 63 } 64 } 65 | Popular Tags |