Extract utils methods

This commit is contained in:
AsamK 2018-11-18 19:51:21 +01:00
parent 35c72f692f
commit 184354ffb7
4 changed files with 272 additions and 224 deletions

View file

@ -3,10 +3,6 @@ package org.asamk.signal.util;
import com.fasterxml.jackson.databind.JsonNode;
import java.io.InvalidObjectException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
public class Util {
@ -23,28 +19,6 @@ public class Util {
return f.toString();
}
public static Map<String, String> getQueryMap(String query) {
String[] params = query.split("&");
Map<String, String> map = new HashMap<>();
for (String param : params) {
String name = null;
final String[] paramParts = param.split("=");
try {
name = URLDecoder.decode(paramParts[0], "utf-8");
} catch (UnsupportedEncodingException e) {
// Impossible
}
String value = null;
try {
value = URLDecoder.decode(paramParts[1], "utf-8");
} catch (UnsupportedEncodingException e) {
// Impossible
}
map.put(name, value);
}
return map;
}
public static String join(CharSequence separator, Iterable<? extends CharSequence> list) {
StringBuilder buf = new StringBuilder();
for (CharSequence str : list) {