Java Map Substitute substitute(String str, Map subs)

Here you can find the source of substitute(String str, Map subs)

Description

substitute

License

Open Source License

Declaration

public static String substitute(String str, Map<String, String> subs) 

Method Source Code

//package com.java2s;

import java.util.Map;

public class Main {
    public static String substitute(String str, Map<String, String> subs) {
        for (Map.Entry<String, String> e : subs.entrySet()) {
            String param = e.getKey();
            if (str.contains(param))
                str = str.replace(param, e.getValue());
        }/* ww w . j av  a2 s  . co m*/
        return str;
    }

    /** Does one string contain another string?
     * @param str1
     * @param str2
     * @return true if str1 contains str2
     */
    public final static boolean contains(String str1, String str2) {
        return str1.contains(str2);
    }

    public final static String replace(String string, String target, String replacement) {
        return string.replace(target, replacement);
    }
}

Related

  1. subsituteAttr(Map attrMap, String text)
  2. substitute(String aString, Map variablesValues, String open, String close)
  3. substitute(String page, String payRef, String name, String emailAddress, String when, String license, Map map)
  4. substitute(String s, Map map)
  5. substitute(String s, Map map)
  6. substitute(String str, Map subs)
  7. substituteExpressionLanguage(String stringToParse, Map variableMap)
  8. substituteForTokens(String input, Map tokenMap, boolean invertMap)
  9. substituteProfileProperty(String key, Map> configs)