
fitnesse.wiki.VariableTool 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.wiki;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import fitnesse.wikitext.VariableSource;
public class VariableTool {
private static final Pattern variablePattern = Pattern.compile("\\$\\{.*}");
private final VariableSource variableSource;
public VariableTool(VariableSource variableSource) {
this.variableSource = variableSource;
}
public String replace(String str) {
Matcher m = variablePattern.matcher(str);
while (m.find()) {
String var = m.group();
Optional value = variableSource.findVariable(var.substring(2, var.length() - 1));
if (value.isPresent()) {
str = str.replace(var, value.get());
}
}
return str;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy