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 37 public class UndoVariableReplacement extends AbstractTransformer 38 { 39 public UndoVariableReplacement( 40 CompoundVariable masterFunction, 41 Map variables) 42 { 43 super(); 44 setMasterFunction(masterFunction); 45 setVariables(variables); 46 } 47 48 51 public JMeterProperty transformValue(JMeterProperty prop) 52 throws InvalidVariableException 53 { 54 Iterator iter = getVariables().keySet().iterator(); 55 String input = prop.getStringValue(); 56 while (iter.hasNext()) 57 { 58 String key = (String ) iter.next(); 59 String value = (String ) getVariables().get(key); 60 input = StringUtilities.substitute(input, "${" + key + "}", value); 61 } 62 StringProperty newProp = new StringProperty(prop.getName(), input); 63 return newProp; 64 } 65 66 } 67 | Popular Tags |