Enhancing the APIClient

This patch adds the getListMapStrValue that returns a list of maps and a
helper method to create a map from json list, it
also adds a stub method for CQL queries.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
Amnon Heiman 2015-07-02 09:18:34 +03:00
parent 2e32584436
commit ad23e435a1

View File

@ -156,6 +156,17 @@ public class APIClient {
return res;
}
public static Map<String, String> mapStrFromJArr(JsonArray arr) {
Map<String, String> res = new HashMap<String, String>();
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
if (obj.containsKey("key") && obj.containsKey("value")) {
res.put(obj.getString("key"), obj.getString("value"));
}
}
return res;
}
public static String join(String[] arr, String joiner) {
String res = "";
if (arr != null) {
@ -426,4 +437,23 @@ public class APIClient {
public JsonArray getJsonArray(String string) {
return getJsonArray(string, null);
}
public List<Map<String, String>> getListMapStrValue(String string,
MultivaluedMap<String, String> queryParams) {
JsonArray arr = getJsonArray(string, queryParams);
List<Map<String, String>> res = new ArrayList<Map<String, String>>();
for (int i = 0; i < arr.size(); i++) {
res.add(mapStrFromJArr(arr.getJsonArray(i)));
}
return res;
}
public List<Map<String, String>> getListMapStrValue(String string) {
return getListMapStrValue(string, null);
}
public TabularData getCQLResult(String string) {
// TODO Auto-generated method stub
return null;
}
}