List of utility methods to do String to Map
Map | stringToMap(String[] strings) Convert an array of String which likes "key=value" to a Map. Map result = new HashMap(); for (int i = 0; i < strings.length; i++) { int pos = strings[i].indexOf('='); if (pos != -1 && pos != 0 && pos != strings[i].length()) { String key = strings[i].substring(0, pos); String value = strings[i].substring(pos + 1); result.put(key, value); return result; |
Map | toMap(String componentName, String contextName) to Map Map<String, String> data = new HashMap<String, String>(); data.put("component.name", componentName); data.put("context.name", contextName); return data; |
Map | toMap(String jsonStr) to Map Map<String, String> newMap = new HashMap<String, String>(); jsonStr = jsonStr.replace("{", "").replace("}", ""); String[] blocks = jsonStr.split(","); for (int i = 0; i < blocks.length; i++) { String block = blocks[i]; int indexOfCarac = block.indexOf("="); if (indexOfCarac < 0) { continue; ... |
Map | toMap(String parameters) to Map return toMap(parameters, null);
|
Map | toMap(String s) to Map Map<String, String> map = new HashMap<String, String>(); if (isNull(s)) return map; String[] ss = toArray(s, ";"); for (int i = 0; i < ss.length; i++) { String[] value = toArray(ss[i], "="); if (value.length == 1) value = toArray(ss[i], ","); ... |
Map | toMap(String s) to Map Map<String, String> m = new HashMap<String, String>(); if (s == null || s.trim().isEmpty()) { return m; String[] tokens = s.split(", "); for (String token : tokens) { String[] kv = token.split(K_V_SEPARATOR); String k = kv[0]; ... |
Map | toMap(String source) to Map HashMap<String, String> responses = new HashMap<String, String>(); String values[] = source.split(";"); for (String value : values) { String nv[] = value.split("="); if (nv.length >= 2) { responses.put(nv[0], nv[1]); } else if (nv.length == 1) { responses.put(nv[0], null); ... |
Map | toMap(String str) to Map Map<String, String> map = new HashMap<String, String>(); String[] strs = str.split("&"); for (int i = 0; i < strs.length; i++) { String[] ss = strs[i].split("="); map.put(ss[0], ss[1]); return map; |