APIClient: getString to return parsed json value
getString should return the string value without the sarounding quotes. For getRaw was introduce that return the API values in its raw value, and getString was changed to use the json parser to get the string values without the quotes. Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com> Signed-off-by: Pekka Enberg <penberg@cloudus-systems.com>
This commit is contained in:
parent
fe3b786053
commit
cce767e47e
@ -104,7 +104,7 @@ public class APIClient {
|
||||
delete(path, null);
|
||||
}
|
||||
|
||||
public String getStringValue(String string,
|
||||
public String getRawValue(String string,
|
||||
MultivaluedMap<String, String> queryParams) {
|
||||
if (!string.equals("")) {
|
||||
return get(string, queryParams).get(String.class);
|
||||
@ -112,13 +112,21 @@ public class APIClient {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getRawValue(String string) {
|
||||
return getRawValue(string, null);
|
||||
}
|
||||
|
||||
public String getStringValue(String string, MultivaluedMap<String, String> queryParams) {
|
||||
return getReader(string, queryParams).toString();
|
||||
}
|
||||
|
||||
public String getStringValue(String string) {
|
||||
return getStringValue(string, null);
|
||||
}
|
||||
|
||||
public JsonReader getReader(String string,
|
||||
MultivaluedMap<String, String> queryParams) {
|
||||
return factory.createReader(new StringReader(getStringValue(string,
|
||||
return factory.createReader(new StringReader(getRawValue(string,
|
||||
queryParams)));
|
||||
}
|
||||
|
||||
@ -133,7 +141,7 @@ public class APIClient {
|
||||
|
||||
public int getIntValue(String string,
|
||||
MultivaluedMap<String, String> queryParams) {
|
||||
return Integer.parseInt(getStringValue(string, queryParams));
|
||||
return Integer.parseInt(getRawValue(string, queryParams));
|
||||
}
|
||||
|
||||
public int getIntValue(String string) {
|
||||
@ -141,11 +149,11 @@ public class APIClient {
|
||||
}
|
||||
|
||||
public boolean getBooleanValue(String string) {
|
||||
return Boolean.parseBoolean(getStringValue(string));
|
||||
return Boolean.parseBoolean(getRawValue(string));
|
||||
}
|
||||
|
||||
public double getDoubleValue(String string) {
|
||||
return Double.parseDouble(getStringValue(string));
|
||||
return Double.parseDouble(getRawValue(string));
|
||||
}
|
||||
|
||||
public List<String> getListStrValue(String string,
|
||||
@ -386,7 +394,7 @@ public class APIClient {
|
||||
}
|
||||
|
||||
public long getLongValue(String string) {
|
||||
return Long.parseLong(getStringValue(string));
|
||||
return Long.parseLong(getRawValue(string));
|
||||
}
|
||||
|
||||
public Map<InetAddress, Float> getMapInetAddressFloatValue(String string,
|
||||
|
Loading…
Reference in New Issue
Block a user