1 18 19 package org.apache.jmeter.engine.util; 20 21 import org.apache.jmeter.threads.JMeterContext; 22 import org.apache.jmeter.threads.JMeterContextService; 23 import org.apache.jmeter.threads.JMeterVariables; 24 25 28 public class SimpleVariable 29 { 30 31 private String name; 32 33 public SimpleVariable(String name) 34 { 35 this.name = name; 36 } 37 38 public SimpleVariable() 39 { 40 this.name = ""; 41 } 42 43 public String getName() 44 { 45 return name; 46 } 47 48 public void setName(String name) 49 { 50 this.name = name; 51 } 52 53 56 public String toString() 57 { 58 String ret = null; 59 JMeterVariables vars = getVariables(); 60 61 if (vars != null) 62 { 63 ret = vars.get(name); 64 } 65 66 if (ret == null) 67 { 68 return "${" + name + "}"; 69 } 70 71 return ret; 72 } 73 74 private JMeterVariables getVariables() 75 { 76 JMeterContext context = JMeterContextService.getContext(); 77 return context.getVariables(); 78 } 79 80 } 81 | Popular Tags |