Firstly, Strings can't be modified in Java so you'll need to create new versions with the correct modified values. There are two ways to approach this problem:
Dynamically hard-code all the replacements like other posters have suggested. This isn't scalable with large strings or a large number of replacements; or
You loop through the String looking for potential variables. If they're in your replacement Map
then replace them. This is very similar to How to create dynamic Template String.
The code for (2) looks something like this:
public static String replaceAll(String text, Map<String, String> params) {
Pattern p = Pattern.compile("&(\\w+)");
Matcher m = p.matcher(text);
boolean result = m.find();
if (result) {
StringBuffer sb = new StringBuffer();
do {
String replacement = params.get(m.group(1));
if (replacement == null) {
replacement = m.group();
}
m.appendReplacement(sb, replacement);
result = m.find();
} while (result);
m.appendTail(sb);
return sb.toString();
}
return text;
}