ConfigTemplate { public String render(Map<String, String> valueMap) { StringBuffer result = new StringBuffer(template.length()); Matcher matcher = TOKEN_PATTERN.matcher(template); while (matcher.find()) { String group = matcher.group(); String[] tokensArray = group.substring(2, group.length() - 2).split("\\|"); String var = tokensArray[0].trim(); String value = valueMap.get(var); if (value == null) { List<String> values = variableMap.get(var); value = values.isEmpty() ? "" : values.get(0); } if (!value.isEmpty() && multilineMap.containsKey(var)) { value = escapeMultilineQuotes(multilineMap.get(var), value); } matcher.appendReplacement(result, Matcher.quoteReplacement(value)); } matcher.appendTail(result); return result.toString(); } ConfigTemplate(String template); String getTemplate(); final void setTemplate(String template); Map<String, List<String>> getVariableMap(); String render(Map<String, String> valueMap); Map<String, String> getMultilineMap();  }
@Test public final void testSimpleCharacters() { ConfigTemplate temp = new ConfigTemplate("{%value%}"); Map<String, String> map = new LinkedHashMap<>(); map.put("value", "sob"); assertEquals("sob", temp.render(map)); }
@Test public final void testSpecialCharacters() { ConfigTemplate temp = new ConfigTemplate("{%value%}"); Map<String, String> map = new LinkedHashMap<>(); map.put("value", "$0b"); assertEquals("$0b", temp.render(map)); }