diff options
author | Godin <mandrikov@gmail.com> | 2010-12-13 08:37:40 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-12-13 08:37:40 +0000 |
commit | 3a7235c0209772229ee4bd82cb0a505729749b3a (patch) | |
tree | e9cf89546a088603a6f00f93907b4b4d0b03ef06 /sonar-gwt-api | |
parent | 30041ec9b27951cd09b7d6b64694f2d179f7ec19 (diff) | |
download | sonarqube-3a7235c0209772229ee4bd82cb0a505729749b3a.tar.gz sonarqube-3a7235c0209772229ee4bd82cb0a505729749b3a.zip |
SONAR-833: New Web Service to get history of measures (time machine)
Diffstat (limited to 'sonar-gwt-api')
-rw-r--r-- | sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java index 53f56ba35dc..d28438fb160 100644 --- a/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java +++ b/sonar-gwt-api/src/main/java/org/sonar/wsclient/gwt/unmarshallers/TimeMachineUnmarshaller.java @@ -1,8 +1,7 @@ package org.sonar.wsclient.gwt.unmarshallers; import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.json.client.JSONArray; -import com.google.gwt.json.client.JSONObject; +import com.google.gwt.json.client.*; import org.sonar.gwt.JsonUtils; import org.sonar.wsclient.services.TimeMachineData; @@ -17,14 +16,26 @@ public class TimeMachineUnmarshaller implements Unmarshaller<TimeMachineData> { JSONArray array = map.get(dateTimeStr).isArray(); List<String> values = new ArrayList<String>(); for (int i = 0; i < JsonUtils.getArraySize(array); i++) { - String value = array.get(i).isString().stringValue(); - values.add(value); + JSONValue elem = array.get(i); + values.add(getAsString(elem)); } data.put(JsonUtils.parseDateTime(dateTimeStr), values); } return new TimeMachineData().setData(data); } + public String getAsString(JSONValue jsonValue) { + if (jsonValue == null) { + return null; + } + JSONString jsonString; + if ((jsonString = jsonValue.isString()) == null) { + JSONNumber jsonNumber = jsonValue.isNumber(); + return jsonNumber != null ? jsonNumber.toString() : null; + } + return jsonString.stringValue(); + } + public List<TimeMachineData> toModels(JavaScriptObject json) { return Arrays.asList(toModel(json)); } |