class StringUtils {

    public static String replace(String s, Map<String, Object> map) {
        StringBuilder ret = new StringBuilder((int) (s.length() * 1.5));
        int cursor = 0;
        for (int start, end; (start = s.indexOf("${", cursor)) != -1 && (end = s.indexOf("}", start)) != -1; ) {
            ret.append(s, cursor, start).append(map.get(s.substring(start + 2, end)));
            cursor = end + 1;
        }
        ret.append(s, cursor, s.length());
        return ret.toString();
    }

}