Java Map Replace replaceAll(String inTemplate, Map inVars)

Here you can find the source of replaceAll(String inTemplate, Map inVars)

Description

replace All

License

Open Source License

Declaration

public static String replaceAll(String inTemplate, Map<String, String> inVars) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static String replaceAll(String inTemplate, Map<String, String> inVars) {

        if (inTemplate == null || inVars == null) {
            return inTemplate;
        }/*from   w ww.ja v a  2  s .com*/

        for (final Entry<String, String> e : inVars.entrySet()) {

            if (e.getKey() == null) {
                continue;
            }

            inTemplate = inTemplate.replace(e.getKey(), e.getValue() == null ? e.getKey() : e.getValue());
        }

        return inTemplate;
    }
}

Related

  1. replace(String temp, Map tags)
  2. replace(String template, Map funcAndDic)
  3. replace(String text, Map pairs)
  4. replace2(String str, Map data)
  5. replaceAll(Map globals, String value)
  6. replaceAll(String template, Map variables)
  7. replaceAllOccurrences(String str, Map replacementMap)
  8. replaceAllRegex(String input, Map replacements)
  9. replaceByMap(String _searchStr, Map _replacements)