MCPcopy Create free account
hub / github.com/antlr/codebuff / split

Method split

corpus/java/training/guava/base/Splitter.java:483–499  ·  view source on GitHub ↗

Splits sequence into substrings, splits each substring into an entry, and returns an unmodifiable map with each of the entries. For example, Splitter.on(';').trimResults().withKeyValueSeparator("=>").split("a=>b ; c=>b") will return a mapping from "a" to "b" and {@cod

(CharSequence sequence)

Source from the content-addressed store, hash-verified

481 * entries, or if there are duplicate keys
482 */
483 public Map<String, String> split(CharSequence sequence) {
484 Map<String, String> map = new LinkedHashMap<String, String>();
485 for (String entry : outerSplitter.split(sequence)) {
486 Iterator<String> entryFields = entrySplitter.splittingIterator(entry);
487
488 checkArgument(entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
489 String key = entryFields.next();
490 checkArgument(!map.containsKey(key), "Duplicate key [%s] found.", key);
491
492 checkArgument(entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
493 String value = entryFields.next();
494 map.put(key, value);
495
496 checkArgument(!entryFields.hasNext(), INVALID_ENTRY_MESSAGE, entry);
497 }
498 return Collections.unmodifiableMap(map);
499 }
500 }
501
502 private interface Strategy {

Callers

nothing calls this directly

Calls 8

nextMethod · 0.65
containsKeyMethod · 0.65
putMethod · 0.65
splitMethod · 0.45
splittingIteratorMethod · 0.45
checkArgumentMethod · 0.45
hasNextMethod · 0.45
unmodifiableMapMethod · 0.45

Tested by

no test coverage detected