@Test public void testProps() { String s1 = "${xxx} : ${yyy}"; String s2 = propertyResolver.resolveProps(s1); Assert.assertEquals(s1, s2); s1 = "${myhost} : ${myport}"; s2 = propertyResolver.resolveProps(s1); Assert.assertEquals("w2 : 1099", s2); s1 = "${myhost} : ${myaltport:2099}"; s2 = propertyResolver.resolveProps(s1); Assert.assertEquals("w2 : 2099", s2); s1 = "${myhost}:2099"; s2 = propertyResolver.resolveProps(s1); Assert.assertEquals("w2:2099", s2); }
public String resolveProps(@Nullable String s) { if (s == null) { return null; } int ipos = 0; int pos = s.indexOf("${", ipos); if (pos == -1) return s; StringBuilder sb = new StringBuilder(); while (ipos < s.length()) { pos = s.indexOf("${", ipos); if (pos < 0) { sb.append(s.substring(ipos)); break; } if (pos != ipos) sb.append(s.substring(ipos, pos)); int end = s.indexOf('}', pos); if (end < 0) break; int start = pos + 2; String key = s.substring(start, end); String val = resolveString(key); if (val != null) sb.append(val); else sb.append("${").append(key).append("}"); ipos = end + 1; } return sb.toString(); }
PropertyResolver implements Serializable { public String resolveProps(@Nullable String s) { if (s == null) { return null; } int ipos = 0; int pos = s.indexOf("${", ipos); if (pos == -1) return s; StringBuilder sb = new StringBuilder(); while (ipos < s.length()) { pos = s.indexOf("${", ipos); if (pos < 0) { sb.append(s.substring(ipos)); break; } if (pos != ipos) sb.append(s.substring(ipos, pos)); int end = s.indexOf('}', pos); if (end < 0) break; int start = pos + 2; String key = s.substring(start, end); String val = resolveString(key); if (val != null) sb.append(val); else sb.append("${").append(key).append("}"); ipos = end + 1; } return sb.toString(); } }
PropertyResolver implements Serializable { public String resolveProps(@Nullable String s) { if (s == null) { return null; } int ipos = 0; int pos = s.indexOf("${", ipos); if (pos == -1) return s; StringBuilder sb = new StringBuilder(); while (ipos < s.length()) { pos = s.indexOf("${", ipos); if (pos < 0) { sb.append(s.substring(ipos)); break; } if (pos != ipos) sb.append(s.substring(ipos, pos)); int end = s.indexOf('}', pos); if (end < 0) break; int start = pos + 2; String key = s.substring(start, end); String val = resolveString(key); if (val != null) sb.append(val); else sb.append("${").append(key).append("}"); ipos = end + 1; } return sb.toString(); }  }
PropertyResolver implements Serializable { public String resolveProps(@Nullable String s) { if (s == null) { return null; } int ipos = 0; int pos = s.indexOf("${", ipos); if (pos == -1) return s; StringBuilder sb = new StringBuilder(); while (ipos < s.length()) { pos = s.indexOf("${", ipos); if (pos < 0) { sb.append(s.substring(ipos)); break; } if (pos != ipos) sb.append(s.substring(ipos, pos)); int end = s.indexOf('}', pos); if (end < 0) break; int start = pos + 2; String key = s.substring(start, end); String val = resolveString(key); if (val != null) sb.append(val); else sb.append("${").append(key).append("}"); ipos = end + 1; } return sb.toString(); }  String resolveProps(@Nullable String s); }
PropertyResolver implements Serializable { public String resolveProps(@Nullable String s) { if (s == null) { return null; } int ipos = 0; int pos = s.indexOf("${", ipos); if (pos == -1) return s; StringBuilder sb = new StringBuilder(); while (ipos < s.length()) { pos = s.indexOf("${", ipos); if (pos < 0) { sb.append(s.substring(ipos)); break; } if (pos != ipos) sb.append(s.substring(ipos, pos)); int end = s.indexOf('}', pos); if (end < 0) break; int start = pos + 2; String key = s.substring(start, end); String val = resolveString(key); if (val != null) sb.append(val); else sb.append("${").append(key).append("}"); ipos = end + 1; } return sb.toString(); }  String resolveProps(@Nullable String s);  }