@Test public void testParameterExpansion() { TextTemplate tt = new TextTemplate(); assertEquals("baz", tt.processText("${foo:=baz}")); Properties vars = new Properties(); vars.setProperty("foo", "bar"); tt = new TextTemplate(vars); assertEquals("bar", tt.processText("${foo:=baz}")); assertEquals("<foo>${myUnresolvedExpression}</foo>", tt.processText("<foo>${myUnresolvedExpression}</foo>")); vars.setProperty("myUnresolvedExpression", ""); assertEquals("<foo></foo>", tt.processText("<foo>${myUnresolvedExpression}</foo>")); }
public String processText(String text) { if (text == null) { return null; } boolean doneProcessing = false; int recursionLevel = 0; while (!doneProcessing) { doneProcessing = true; String processedText = processString(vars, text); if (!processedText.equals(text)) { doneProcessing = false; text = processedText; } recursionLevel++; if (!doneProcessing && recursionLevel > MAX_RECURSION_LEVEL) { log.warn("Detected potential infinite loop when processing the following text\n" + text); break; } } return unescape(text); }
TextTemplate { public String processText(String text) { if (text == null) { return null; } boolean doneProcessing = false; int recursionLevel = 0; while (!doneProcessing) { doneProcessing = true; String processedText = processString(vars, text); if (!processedText.equals(text)) { doneProcessing = false; text = processedText; } recursionLevel++; if (!doneProcessing && recursionLevel > MAX_RECURSION_LEVEL) { log.warn("Detected potential infinite loop when processing the following text\n" + text); break; } } return unescape(text); } }
TextTemplate { public String processText(String text) { if (text == null) { return null; } boolean doneProcessing = false; int recursionLevel = 0; while (!doneProcessing) { doneProcessing = true; String processedText = processString(vars, text); if (!processedText.equals(text)) { doneProcessing = false; text = processedText; } recursionLevel++; if (!doneProcessing && recursionLevel > MAX_RECURSION_LEVEL) { log.warn("Detected potential infinite loop when processing the following text\n" + text); break; } } return unescape(text); } TextTemplate();  TextTemplate(Map<String, String> vars);  TextTemplate(Properties vars); }
TextTemplate { public String processText(String text) { if (text == null) { return null; } boolean doneProcessing = false; int recursionLevel = 0; while (!doneProcessing) { doneProcessing = true; String processedText = processString(vars, text); if (!processedText.equals(text)) { doneProcessing = false; text = processedText; } recursionLevel++; if (!doneProcessing && recursionLevel > MAX_RECURSION_LEVEL) { log.warn("Detected potential infinite loop when processing the following text\n" + text); break; } } return unescape(text); } TextTemplate();  TextTemplate(Map<String, String> vars);  TextTemplate(Properties vars); boolean isTrim(); void setTrim(boolean trim); void setVariables(Map<String, String> vars); void setVariable(String name, String value); String getVariable(String name); Properties getVariables(); Properties preprocessVars(Properties unprocessedVars); String processText(String text); String processText(InputStream in); void processText(InputStream is, OutputStreamWriter os); @SuppressWarnings("unchecked") void initFreeMarker(); void processFreemarker(File in, File out); List<String> processDirectory(File in, File out); void setTextParsingExtensions(String extensionsList); void setFreemarkerParsingExtensions(String extensionsList); void setKeepEncryptedAsVar(boolean keepEncryptedAsVar); }
TextTemplate { public String processText(String text) { if (text == null) { return null; } boolean doneProcessing = false; int recursionLevel = 0; while (!doneProcessing) { doneProcessing = true; String processedText = processString(vars, text); if (!processedText.equals(text)) { doneProcessing = false; text = processedText; } recursionLevel++; if (!doneProcessing && recursionLevel > MAX_RECURSION_LEVEL) { log.warn("Detected potential infinite loop when processing the following text\n" + text); break; } } return unescape(text); } TextTemplate();  TextTemplate(Map<String, String> vars);  TextTemplate(Properties vars); boolean isTrim(); void setTrim(boolean trim); void setVariables(Map<String, String> vars); void setVariable(String name, String value); String getVariable(String name); Properties getVariables(); Properties preprocessVars(Properties unprocessedVars); String processText(String text); String processText(InputStream in); void processText(InputStream is, OutputStreamWriter os); @SuppressWarnings("unchecked") void initFreeMarker(); void processFreemarker(File in, File out); List<String> processDirectory(File in, File out); void setTextParsingExtensions(String extensionsList); void setFreemarkerParsingExtensions(String extensionsList); void setKeepEncryptedAsVar(boolean keepEncryptedAsVar);  }