Java Map Replace replace(Map map, String content)

Here you can find the source of replace(Map map, String content)

Description

replace

License

Open Source License

Declaration

private static String replace(Map<String, String> map, String content) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    private static String replace(Map<String, String> map, String content) {
        if (content == null) {
            return null;
        }/*from  w  w  w.jav  a2 s  .c o  m*/
        Map<String, String> newmap = new HashMap<String, String>();
        for (String key : map.keySet()) {
            if (map.get(key) != null) {
                newmap.put("${" + key + "}", map.get(key));
            }
        }
        for (String key : newmap.keySet()) {
            String old = "";
            do {
                old = content;
                content = content.replace(key, newmap.get(key));
            } while (!old.equals(content));
        }
        return content;
    }
}

Related

  1. replace(Map map, String text)
  2. replace(String originalCommand, Map vars)
  3. replace(String orign, Map replaceStringMap)
  4. replace(String s, Map map)