@Test public void extractInterpolationVariablesNoVariables() { String string = "foo bar baz"; Collection<InterpolationVariable> interpolationVariables = TemplateUtils.extractInterpolationVariables(string); assertTrue(interpolationVariables.isEmpty()); }
public static Collection<InterpolationVariable> extractInterpolationVariables(final String text) { if (text == null || text.length() == 0) { return Collections.emptyList(); } List<InterpolationVariable> interpolationVariableList = new ArrayList<>(); int pos = 0; while ((pos = text.indexOf("@{", pos)) != -1) { int end = text.indexOf('}', pos + 2); if (end != -1) { String varName = text.substring(pos + 2, end); pos = end + 1; InterpolationVariable var = new InterpolationVariable(varName, DataType.TYPE_OBJECT); interpolationVariableList.add(var); } else { break; } } return interpolationVariableList; }
TemplateUtils { public static Collection<InterpolationVariable> extractInterpolationVariables(final String text) { if (text == null || text.length() == 0) { return Collections.emptyList(); } List<InterpolationVariable> interpolationVariableList = new ArrayList<>(); int pos = 0; while ((pos = text.indexOf("@{", pos)) != -1) { int end = text.indexOf('}', pos + 2); if (end != -1) { String varName = text.substring(pos + 2, end); pos = end + 1; InterpolationVariable var = new InterpolationVariable(varName, DataType.TYPE_OBJECT); interpolationVariableList.add(var); } else { break; } } return interpolationVariableList; } }
TemplateUtils { public static Collection<InterpolationVariable> extractInterpolationVariables(final String text) { if (text == null || text.length() == 0) { return Collections.emptyList(); } List<InterpolationVariable> interpolationVariableList = new ArrayList<>(); int pos = 0; while ((pos = text.indexOf("@{", pos)) != -1) { int end = text.indexOf('}', pos + 2); if (end != -1) { String varName = text.substring(pos + 2, end); pos = end + 1; InterpolationVariable var = new InterpolationVariable(varName, DataType.TYPE_OBJECT); interpolationVariableList.add(var); } else { break; } } return interpolationVariableList; } private  TemplateUtils(); }
TemplateUtils { public static Collection<InterpolationVariable> extractInterpolationVariables(final String text) { if (text == null || text.length() == 0) { return Collections.emptyList(); } List<InterpolationVariable> interpolationVariableList = new ArrayList<>(); int pos = 0; while ((pos = text.indexOf("@{", pos)) != -1) { int end = text.indexOf('}', pos + 2); if (end != -1) { String varName = text.substring(pos + 2, end); pos = end + 1; InterpolationVariable var = new InterpolationVariable(varName, DataType.TYPE_OBJECT); interpolationVariableList.add(var); } else { break; } } return interpolationVariableList; } private  TemplateUtils(); static Collection<InterpolationVariable> extractInterpolationVariables(final String text); static String substituteTemplateVariable(final String text,
                                                    final Function<String, String> keyToValueFunction); }
TemplateUtils { public static Collection<InterpolationVariable> extractInterpolationVariables(final String text) { if (text == null || text.length() == 0) { return Collections.emptyList(); } List<InterpolationVariable> interpolationVariableList = new ArrayList<>(); int pos = 0; while ((pos = text.indexOf("@{", pos)) != -1) { int end = text.indexOf('}', pos + 2); if (end != -1) { String varName = text.substring(pos + 2, end); pos = end + 1; InterpolationVariable var = new InterpolationVariable(varName, DataType.TYPE_OBJECT); interpolationVariableList.add(var); } else { break; } } return interpolationVariableList; } private  TemplateUtils(); static Collection<InterpolationVariable> extractInterpolationVariables(final String text); static String substituteTemplateVariable(final String text,
                                                    final Function<String, String> keyToValueFunction);  }