Java Map Replace replaceSeparator(String value, String separator, Map map)

Here you can find the source of replaceSeparator(String value, String separator, Map map)

Description

replace Separator

License

Open Source License

Declaration

public static String replaceSeparator(String value, String separator, Map<String, String> map) 

Method Source Code

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

import java.util.Map;

public class Main {

    public static String replaceSeparator(String value, String separator, Map<String, String> map) {
        if (map == null || map.size() == 0) {
            return value;
        }/*from   w  ww . j av a2s.c  o m*/
        StringBuilder sb = new StringBuilder();
        String[] valueSplit = value.split(separator);
        for (int i = 0; i < valueSplit.length; i++) {
            String replace = map.get(valueSplit[i]);
            if (null != replace && !"".equals(replace)) {
                sb.append(replace);
            } else {
                sb.append(valueSplit[i]);
            }
            if (i < valueSplit.length - 1) {
                sb.append(separator);
            }
        }
        return sb.toString();
    }
}

Related

  1. replaceParams(String str, Map map)
  2. replacePlaceholders(String script, Map configurations)
  3. replacePlaceholders(String string, Map values)
  4. replaceProperties(final CharSequence string, final Map properties)
  5. replaceQueryParameterInUrl(String fullUrl, Map newParameter)
  6. replaceString(Map bodyToReplace, String replacingContent)
  7. replaceString(String source, Map args)
  8. replaceString(String uri, String baseURI, Map prefixes)
  9. replaceTemplates(String template, Map entries)