// building table for the Table
DataTable dtbl = new DataTable(title.toString());
// building a second table for the chart
DataTable dtblChart = new DataTable(title.toString());
//
DataRow dataRowChart;
DataRow dataRow;
// each data row comes out as an Array of Objects
// the only way to extract the data is by knowing
// in which order they come out
for (Object obj : list) {
dataRowChart = new DataRow(null);
dataRow = new DataRow(null);
Object[] objArr = (Object[]) obj;
try {
// getting localized time group unit
// String identifier = timeGrouping.getTitle();
// setting row name with localized time group and the date/time extraction based on the group
dataRowChart.setName(new Converter(objArr[2]).getString() + "");
dataRow.setName(new Converter(objArr[2]).getString() + "");
// dataRow.setName(new Converter(objArr[2]).getString());
// building up row depending on requested output having different fields
switch (this.cu) {
case volumesAndPages: {
dataRowChart.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble()));
dataRowChart.addValue(CalculationUnit.pages.getTitle() + " (*100)", (new Converter(objArr[1]).getDouble()) / 100);
dataRow.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble()));
dataRow.addValue(CalculationUnit.pages.getTitle(), (new Converter(objArr[1]).getDouble()));
}
break;
case volumes: {
dataRowChart.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble()));
dataRow.addValue(CalculationUnit.volumes.getTitle(), (new Converter(objArr[0]).getDouble()));
}
break;
case pages: {
dataRowChart.addValue(CalculationUnit.pages.getTitle(), (new Converter(objArr[1]).getDouble()));
dataRow.addValue(CalculationUnit.pages.getTitle(), (new Converter(objArr[1]).getDouble()));
}
break;
}
// fall back, if conversion triggers an exception
} catch (Exception e) {
dataRowChart.addValue(e.getMessage(), new Double(0));
dataRow.addValue(e.getMessage(), new Double(0));
}
// finally adding dataRow to DataTable and fetching next row
// adding the extra table
dtblChart.addDataRow(dataRowChart);