1 18 19 package org.apache.jmeter.protocol.http.modifier; 20 21 import java.io.Serializable ; 22 23 import org.apache.jmeter.testelement.AbstractTestElement; 24 import org.apache.jmeter.testelement.property.LongProperty; 25 26 34 public class ParamMask extends AbstractTestElement implements Serializable 35 { 36 private String PREFIX = "ParamModifier.prefix"; 37 private String FIELD_NAME = "ParamModifier.field_name"; 38 private String UPPER_BOUND = "ParamModifier.upper_bound"; 39 private String LOWER_BOUND = "ParamModifier.lower_bound"; 40 private String INCREMENT = "ParamModifier.increment"; 41 private String SUFFIX = "ParamModifier.suffix"; 42 43 private long _value = 0; 44 45 48 public ParamMask() 49 { 50 setFieldName(""); 51 setPrefix(""); 52 setLowerBound(0); 53 setUpperBound(0); 54 setIncrement(0); 55 setSuffix(""); 56 } 57 58 65 public void setPrefix(String prefix) 66 { 67 setProperty(PREFIX, prefix); 68 } 69 70 77 public void setValue(long val) 78 { 79 _value = val; 80 } 81 82 public void setFieldName(String fieldName) 83 { 84 setProperty(FIELD_NAME, fieldName); 85 } 86 87 93 public void setLowerBound(long val) 94 { 95 setProperty(new LongProperty(LOWER_BOUND, val)); 96 } 97 98 104 public void setUpperBound(long val) 105 { 106 setProperty(new LongProperty(UPPER_BOUND, val)); 107 } 108 109 115 public void setIncrement(long incr) 116 { 117 setProperty(new LongProperty(INCREMENT, incr)); 118 } 119 120 127 public void setSuffix(String suffix) 128 { 129 setProperty(SUFFIX, suffix); 130 } 131 132 138 public String getPrefix() 139 { 140 return getPropertyAsString(PREFIX); 141 } 142 143 149 public long getLowerBound() 150 { 151 return getPropertyAsLong(LOWER_BOUND); 152 } 153 154 160 public long getUpperBound() 161 { 162 return getPropertyAsLong(UPPER_BOUND); 163 } 164 165 171 public long getIncrement() 172 { 173 return getPropertyAsLong(INCREMENT); 174 } 175 176 182 public String getSuffix() 183 { 184 return getPropertyAsString(SUFFIX); 185 } 186 187 192 193 204 public String getNextValue() 205 { 206 String retval = getPrefix() + Long.toString(_value) + getSuffix(); 208 209 _value += getIncrement(); 211 if (_value > getUpperBound()) 212 { 213 _value = getLowerBound(); 214 } 215 216 return retval; 217 } 218 219 223 public void resetValue() 224 { 225 _value = getLowerBound(); 226 } 227 228 public String getFieldName() 229 { 230 return getPropertyAsString(FIELD_NAME); 231 } 232 233 238 public String toString() 239 { 240 StringBuffer sb = new StringBuffer (); 241 sb.append("-------------------------------\n"); 242 sb.append("Dumping ParamMask Object\n"); 243 sb.append("-------------------------------\n"); 244 sb.append("Name = " + getFieldName() + "\n"); 245 sb.append("Prefix = " + getPrefix() + "\n"); 246 sb.append("Current Value = " + _value + "\n"); 247 sb.append("Lower Bound = " + getLowerBound() + "\n"); 248 sb.append("Upper Bound = " + getUpperBound() + "\n"); 249 sb.append("Increment = " + getIncrement() + "\n"); 250 sb.append("Suffix = " + getSuffix() + "\n"); 251 sb.append("-------------------------------\n"); 252 253 return sb.toString(); 254 } 255 } 256 | Popular Tags |