Method from org.apache.jmeter.engine.util.CompoundVariable Detail: |
public void clear() {
// TODO should this also clear isDynamic, rawParameters, permanentResults?
hasFunction = false;
compiledComponents.clear();
}
|
public String execute() {
if (isDynamic) {
JMeterContext context = JMeterContextService.getContext();
SampleResult previousResult = context.getPreviousResult();
Sampler currentSampler = context.getCurrentSampler();
return execute(previousResult, currentSampler);
}
return permanentResults; // $NON-NLS-1$
}
|
public String execute(SampleResult previousResult,
Sampler currentSampler) {
if (compiledComponents == null || compiledComponents.size() == 0) {
return ""; // $NON-NLS-1$
}
boolean testDynamic = false;
StringBuffer results = new StringBuffer();
Iterator iter = compiledComponents.iterator();
while (iter.hasNext()) {
Object item = iter.next();
if (item instanceof Function) {
testDynamic = true;
try {
results.append(((Function) item).execute(previousResult, currentSampler));
} catch (InvalidVariableException e) {
}
} else if (item instanceof SimpleVariable) {
testDynamic = true;
results.append(((SimpleVariable) item).toString());
} else {
results.append(item);
}
}
if (!testDynamic) {
isDynamic = false;
permanentResults = results.toString();
}
return results.toString();
}
|
public List getArgumentDesc() {
return new LinkedList();
}
|
public CompoundVariable getFunction() {
CompoundVariable func = new CompoundVariable();
func.compiledComponents = (LinkedList) compiledComponents.clone();
func.rawParameters = rawParameters;
return func;
}
|
static Object getNamedFunction(String functionName) throws InvalidVariableException {
if (functions.containsKey(functionName)) {
try {
return ((Class) functions.get(functionName)).newInstance();
} catch (Exception e) {
log.error("", e); // $NON-NLS-1$
throw new InvalidVariableException();
}
}
return new SimpleVariable(functionName);
}
|
public String getRawParameters() {
return rawParameters;
}
Allows the retrieval of the original String prior to it being compiled. |
public String getReferenceKey() {
return ""; // $NON-NLS-1$
}
|
public boolean hasFunction() {
return hasFunction;
}
|
public void setParameters(String parameters) throws InvalidVariableException {
this.rawParameters = parameters;
if (parameters == null || parameters.length() == 0) {
return;
}
compiledComponents = functionParser.compileString(parameters);
if (compiledComponents.size() > 1 || !(compiledComponents.get(0) instanceof String)) {
hasFunction = true;
}
}
|
public void setParameters(Collection parameters) throws InvalidVariableException {
}
|