Java Map Replace replaceInvalid(String uri, Map reps)

Here you can find the source of replaceInvalid(String uri, Map reps)

Description

replace Invalid

License

Apache License

Declaration

private static String replaceInvalid(String uri, Map<String, String> reps) 

Method Source Code

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

import java.util.Map;

public class Main {
    private static String replaceInvalid(String uri, Map<String, String> reps) {

        // replace invalid characters
        StringBuilder builder = new StringBuilder();
        for (char curChar : uri.toCharArray()) {
            String charStr = String.valueOf(curChar);
            if (reps.containsKey(charStr)) {
                builder.append("%" + reps.get(charStr));
            } else {
                builder.append(charStr);
            }/*  w  ww . ja va2s.c o  m*/
        }
        return builder.toString();
    }
}

Related

  1. replaceElements(Map destinationMap, Map sourceMap)
  2. replaceEntities(final Map replacements, final String xml)
  3. replaceFromMap(final String string, final Map replacements)
  4. replaceFromMap(String string, Map replacements)
  5. replaceGlobalTokensFromMap(Map dataMap, String message)
  6. replaceKey(final Map map, final TKey oldkey, final TKey newkey)
  7. replaceKey(Map map, K oldKey, K newKey)
  8. replaceKeyCharacter(Map map, char oldChar, char newChar)
  9. replaceKeyword(String messageTemplate, Map args, String key)