fitnesse.slim.VariableStore Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
The newest version!
package fitnesse.slim;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class VariableStore {
private Map variables = new HashMap<>();
public void setSymbol(String name, MethodExecutionResult value) {
variables.put(name, value);
}
public MethodExecutionResult getSymbol(String name) {
return variables.get(name);
}
public Object getStored(String nameWithDollar) {
if (nameWithDollar == null || !nameWithDollar.startsWith("$"))
return null;
if (nameWithDollar.startsWith("$`") && nameWithDollar.endsWith("`")) {
String expr = nameWithDollar.substring(2, nameWithDollar.length() - 1);
return evaluate(expr);
} else {
String name = nameWithDollar.substring(1);
if (!variables.containsKey(name)) {
return null;
}
return variables.get(name).getObject();
}
}
private boolean containsValueFor(String nameWithDollar) {
boolean result = false;
if (nameWithDollar != null) {
if (nameWithDollar.startsWith("$`") && nameWithDollar.endsWith("`")) {
result = true;
} else if (nameWithDollar.startsWith("$")) {
if (variables.containsKey(nameWithDollar.substring(1))) {
result = true;
}
}
}
return result;
}
public Object[] replaceSymbols(Object[] args) {
Object[] result = new Object[args.length];
for (int i = 0; i < args.length; i++)
result[i] = replaceSymbol(args[i]);
return result;
}
private List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy