public final String finishRow() {
int listindex = ((List) getDecoratedObject()).indexOf(this.getCurrentRowObject());
ReportableListObject reportableObject = (ReportableListObject) this.getCurrentRowObject();
String nextCity = null;
this.cityTotal += reportableObject.getAmount();
this.grandTotal += reportableObject.getAmount();
if (listindex != ((List) getDecoratedObject()).size() - 1)
{
nextCity = ((ReportableListObject) ((List) getDecoratedObject()).get(listindex + 1)).getCity();
}
this.buffer = new StringBuffer(1000);
// City subtotals...
if (!ObjectUtils.equals(nextCity, reportableObject.getCity()))
{
writeCityTotal(reportableObject.getCity(), this.cityTotal);
this.cityTotal = 0;
}
// Grand totals...
if (getViewIndex() == ((List) getDecoratedObject()).size() - 1)
{
writeGrandTotal(this.grandTotal);
}
return buffer.toString();
}
After every row completes we evaluate to see if we should be drawing a new total line and summing the results
from the previous group. |