List of utility methods to do Map Replace
String | replaceTemplates(String template, Map replace Templates for (Map.Entry<String, String> e : entries.entrySet()) { template = template.replaceAll(e.getKey(), e.getValue()); return template; |
String | replaceTokens(String inputString, Map Replace all tokens in a String. StringBuilder ret = new StringBuilder(inputString.length() + 10); Iterator<String> iter = tokenMap.keySet().iterator(); ret.append(inputString); while (iter.hasNext()) { String token = iter.next(); String value = tokenMap.get(token); int found = 0; while ((found = ret.indexOf(token, found)) > 0) { ... |
StringBuilder | replaceToStringBuilder(String s, String begin, String end, Map replace To String Builder if ((s == null) || (begin == null) || (end == null) || (values == null) || (values.size() == 0)) { return new StringBuilder(s); StringBuilder sb = new StringBuilder(values.size() * 2 + 1); int pos = 0; while (true) { int x = s.indexOf(begin, pos); int y = s.indexOf(end, x + begin.length()); ... |
String | replaceValues(String s, String begin, String end, Map values) Returns a string with replaced values. if ((s == null) || (begin == null) || (end == null) || (values == null) || (values.size() == 0)) { return s; StringBuffer sm = new StringBuffer(s.length()); int pos = 0; while (true) { int x = s.indexOf(begin, pos); int y = s.indexOf(end, x + begin.length()); ... |
Map | replaceValuesToSynonyms(Map replace Values To Synonyms Map<K, V> ret = new HashMap<K, V>(dic); for (K key : dic.keySet()) { V value = dic.get(key); if (synonims.containsKey(value)) ret.put(key, synonims.get(value)); return ret; |
String | replaceVariable(final String src, final Map replace Variable int len = src.length(); StringBuffer buf = new StringBuffer(len); for (int i = 0; i < len; i++) { char c = src.charAt(i); if (c == '$') { i++; StringBuffer key = new StringBuffer(); char temp = src.charAt(i); ... |
String | replaceVariables(String chart, Map replace Variables modifyVariables(variables, true); chart = chart.replaceAll("\\*\\{[\\w\\W]*?\\}\\*", ""); for (String key : variables.keySet()) { String val = variables.get(key); chart = chart.replaceAll("\\$\\{" + key + "\\}", val); return chart; |
String | replaceVars(String origString, Map vars) Performs variable substitution for a string. StringBuffer finalString = new StringBuffer(); int index = 0; int i = 0; String key = null; String value = null; while ((index = origString.indexOf("${", i)) > -1) { key = origString.substring(index + 2, origString.indexOf("}", index + 3)); value = (String) vars.get(key); ... |
String | replaceVars(String s, Map Simple utility for replacing variables of the form if (s.indexOf('{') == -1) return s; int S1 = 1; int S2 = 2; int state = S1; boolean hasInternalVar = false; int x = 0; int depth = 0; ... |
String | stringReplace(Map string Replace String tmp = line; for (Map.Entry<String, String> entry : map.entrySet()) { String target = entry.getKey(); String replacement = entry.getValue(); tmp = tmp.replace(target, replacement); return tmp; |