@Test public void testProcessTemplateString() { System.setProperty("test", "testvalue"); assertEquals("testvalue", ConfigurationUtils.processTemplate("${test}")); assertEquals("embedded testvalue", ConfigurationUtils.processTemplate("embedded ${test}")); }
public static String processTemplate(String text) { if (text.indexOf("${") >= 0 && text.indexOf("}") > 2) { Map<Object, Object> systemProperties = new HashMap<Object, Object>(System.getProperties()); for (Entry<Object, Object> entry : systemProperties.entrySet()) { String variable = "\\$\\{" + (String) entry.getKey() + "\\}"; String replacement = (String) entry.getValue(); text = text.replaceAll(variable, replacement); } Map<String, String> systemEnv = new HashMap<String, String>(System.getenv()); for (Entry<String, String> entry : systemEnv.entrySet()) { String variable = "\\$\\{" + entry.getKey() + "\\}"; String replacement = entry.getValue(); text = text.replaceAll(variable, replacement); } } return text; }
ConfigurationUtils { public static String processTemplate(String text) { if (text.indexOf("${") >= 0 && text.indexOf("}") > 2) { Map<Object, Object> systemProperties = new HashMap<Object, Object>(System.getProperties()); for (Entry<Object, Object> entry : systemProperties.entrySet()) { String variable = "\\$\\{" + (String) entry.getKey() + "\\}"; String replacement = (String) entry.getValue(); text = text.replaceAll(variable, replacement); } Map<String, String> systemEnv = new HashMap<String, String>(System.getenv()); for (Entry<String, String> entry : systemEnv.entrySet()) { String variable = "\\$\\{" + entry.getKey() + "\\}"; String replacement = entry.getValue(); text = text.replaceAll(variable, replacement); } } return text; } }
ConfigurationUtils { public static String processTemplate(String text) { if (text.indexOf("${") >= 0 && text.indexOf("}") > 2) { Map<Object, Object> systemProperties = new HashMap<Object, Object>(System.getProperties()); for (Entry<Object, Object> entry : systemProperties.entrySet()) { String variable = "\\$\\{" + (String) entry.getKey() + "\\}"; String replacement = (String) entry.getValue(); text = text.replaceAll(variable, replacement); } Map<String, String> systemEnv = new HashMap<String, String>(System.getenv()); for (Entry<String, String> entry : systemEnv.entrySet()) { String variable = "\\$\\{" + entry.getKey() + "\\}"; String replacement = entry.getValue(); text = text.replaceAll(variable, replacement); } } return text; } private  ConfigurationUtils(); }
ConfigurationUtils { public static String processTemplate(String text) { if (text.indexOf("${") >= 0 && text.indexOf("}") > 2) { Map<Object, Object> systemProperties = new HashMap<Object, Object>(System.getProperties()); for (Entry<Object, Object> entry : systemProperties.entrySet()) { String variable = "\\$\\{" + (String) entry.getKey() + "\\}"; String replacement = (String) entry.getValue(); text = text.replaceAll(variable, replacement); } Map<String, String> systemEnv = new HashMap<String, String>(System.getenv()); for (Entry<String, String> entry : systemEnv.entrySet()) { String variable = "\\$\\{" + entry.getKey() + "\\}"; String replacement = entry.getValue(); text = text.replaceAll(variable, replacement); } } return text; } private  ConfigurationUtils(); static Object getValue(Object object, Object defaultObject); static Object getValue(Object object, Object defaultObject,
      boolean processTemplates); static int getValue(String value, int defaultValue); static long getValue(String value, long defaultValue); static String[] getMultiOptionValues(String optionValue); static boolean isDefault(Node node); static boolean isTrue(Node node); static boolean isTrue(String value); static boolean isTrue(String value, boolean defaultValue); static boolean isFalse(String value); static boolean isFalse(String value, boolean defaultValue); static boolean isEnabled(String value); static boolean isEnabled(String value, boolean defaultValue); static boolean isDisabled(String value); static boolean isDisabled(String value, boolean defaultValue); static String toHumanReadableDuration(long millis); static String toDuration(long millis); static long parseDuration(String duration); static String processTemplate(String text); static String processTemplate(String text,
      Map<String, String> variables); static String processTemplate(String text, Module module,
      Environment environment); static String processTemplate(String text, Site site,
      Environment environment); }
ConfigurationUtils { public static String processTemplate(String text) { if (text.indexOf("${") >= 0 && text.indexOf("}") > 2) { Map<Object, Object> systemProperties = new HashMap<Object, Object>(System.getProperties()); for (Entry<Object, Object> entry : systemProperties.entrySet()) { String variable = "\\$\\{" + (String) entry.getKey() + "\\}"; String replacement = (String) entry.getValue(); text = text.replaceAll(variable, replacement); } Map<String, String> systemEnv = new HashMap<String, String>(System.getenv()); for (Entry<String, String> entry : systemEnv.entrySet()) { String variable = "\\$\\{" + entry.getKey() + "\\}"; String replacement = entry.getValue(); text = text.replaceAll(variable, replacement); } } return text; } private  ConfigurationUtils(); static Object getValue(Object object, Object defaultObject); static Object getValue(Object object, Object defaultObject,
      boolean processTemplates); static int getValue(String value, int defaultValue); static long getValue(String value, long defaultValue); static String[] getMultiOptionValues(String optionValue); static boolean isDefault(Node node); static boolean isTrue(Node node); static boolean isTrue(String value); static boolean isTrue(String value, boolean defaultValue); static boolean isFalse(String value); static boolean isFalse(String value, boolean defaultValue); static boolean isEnabled(String value); static boolean isEnabled(String value, boolean defaultValue); static boolean isDisabled(String value); static boolean isDisabled(String value, boolean defaultValue); static String toHumanReadableDuration(long millis); static String toDuration(long millis); static long parseDuration(String duration); static String processTemplate(String text); static String processTemplate(String text,
      Map<String, String> variables); static String processTemplate(String text, Module module,
      Environment environment); static String processTemplate(String text, Site site,
      Environment environment);  }