for (int i = 0; i < size; i++) {
JSONObject cellJson = JsonUtils.getArray(cells, i);
JSONArray valuesJson = cellJson.get("v").isArray();
+
Object[] resultValues = new Object[JsonUtils.getArraySize(valuesJson)];
for (int indexValue = 0; indexValue < JsonUtils.getArraySize(valuesJson); indexValue++) {
Object value = valuesJson.get(indexValue);
return null;
}
- /**
- * @since 2.5
- */
- public static Date parseDateTime(String dateTime) {
- try {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
- return dateFormat.parse(dateTime);
- } catch (ParseException e) {
- throw new RuntimeException(e);
- }
- }
}
int size = cols.size();
TimeMachineColumn[] result = new TimeMachineColumn[size];
for (int index = 0; index < size; index++) {
- JSONObject colJson = (JSONObject)cols.get(index);
- result[index]=new TimeMachineColumn(index, JsonUtils.getString(colJson, "metric"), null, null);
+ JSONObject colJson = (JSONObject) cols.get(index);
+ result[index] = new TimeMachineColumn(index, JsonUtils.getString(colJson, "metric"), null, null);
}
return result;
}
int size = cells.size();
TimeMachineCell[] result = new TimeMachineCell[size];
for (int i = 0; i < size; i++) {
- JSONObject cellJson = (JSONObject)cells.get(i);
+ JSONObject cellJson = (JSONObject) cells.get(i);
JSONArray valuesJson = JsonUtils.getArray(cellJson, "v");
Object[] resultValues = new Object[valuesJson.size()];
for (int indexValue = 0; indexValue < valuesJson.size(); indexValue++) {
Object value = valuesJson.get(indexValue);
- resultValues[indexValue]=value;
+ resultValues[indexValue] = value;
}
- result[i]=new TimeMachineCell(JsonUtils.getDateTime(cellJson, "d"), resultValues);
+ result[i] = new TimeMachineCell(JsonUtils.getDateTime(cellJson, "d"), resultValues);
}
return result;
}
TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/typed-values.json"));
assertThat(timeMachine.getCells()[0].getValues().length, is(2));
- assertThat((String)timeMachine.getCells()[0].getValues()[0], is("Sonar way"));
+ assertThat((String) timeMachine.getCells()[0].getValues()[0], is("Sonar way"));
assertThat((Double) timeMachine.getCells()[0].getValues()[1], is(80.0));
-
}
}