MCPcopy Create free account
hub / github.com/GateNLP/gate-core / toMap

Method toMap

src/main/java/gate/util/Strings.java:290–308  ·  view source on GitHub ↗

Get back a Map of String String from its String representation. Unescape backslashed separator characters. @param string String to convert to a Map @return a Map @see #toString(java.util.Map)

(String string)

Source from the content-addressed store, hash-verified

288 * @see #toString(java.util.Map)
289 */
290 public static Map<String, String> toMap(String string) {
291 Map<String, String> map = new HashMap<String, String>();
292 if (string == null
293 || string.length() < 3) {
294 return map;
295 }
296 Set<String> firstList = toSet(string, ", ");
297 for (String element : firstList) {
298 LinkedHashSet<String> secondList = toSet("[" + element + "]", "=");
299 if (secondList.size() == 2) {
300 Iterator<String> iterator = secondList.iterator();
301 map.put(iterator.next(), iterator.next());
302 } else {
303 Err.prln("Ignoring element: [" + element + "]");
304 Err.prln("Expecting: [key=value]");
305 }
306 }
307 return map;
308 }
309
310 /**
311 * Crop the text in the middle if too long.

Callers 1

getMapMethod · 0.95

Calls 7

toSetMethod · 0.95
prlnMethod · 0.95
sizeMethod · 0.65
iteratorMethod · 0.65
nextMethod · 0.65
lengthMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected