Java Map Substitute substitute(String page, String payRef, String name, String emailAddress, String when, String license, Map map)

Here you can find the source of substitute(String page, String payRef, String name, String emailAddress, String when, String license, Map map)

Description

substitute

License

Apache License

Declaration

public static String substitute(String page, String payRef, String name, String emailAddress, String when,
            String license, Map<String, String> map) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Map;

public class Main {
    public static String substitute(String page, String payRef, String name, String emailAddress, String when,
            String license, Map<String, String> map) {
        String x = page;/*from w  w w. j a va2 s.c  om*/
        for (Map.Entry<String, String> en : map.entrySet()) {
            x = replace(x, en.getKey(), en.getValue());
        }
        x = x.replace("$PAYREF$", payRef);
        x = x.replace("$NAME$", name);
        x = x.replace("$EMAIL$", emailAddress);
        x = x.replace("$WHEN$", when);
        x = x.replace("$LICENCE$", license);
        return x;
    }

    private static String replace(String x, String key, String value) {
        String replaceKey = "$" + key.toUpperCase() + "$";
        return x.replace(replaceKey, value);
    }
}

Related

  1. subsituteAttr(Map attrMap, String text)
  2. substitute(String aString, Map variablesValues, String open, String close)
  3. substitute(String s, Map map)
  4. substitute(String s, Map map)
  5. substitute(String str, Map subs)
  6. substitute(String str, Map subs)