}
public ProcessState commit(final ProcessState next) throws ReportProcessingException
{
next.leaveGroup();
final DefaultFlowController fc = next.getFlowController();
final boolean advanceRequested = fc.isAdvanceRequested();
final boolean advanceable = fc.getMasterRow().isAdvanceable();
if (isRootGroup(next))
{
// there is no parent group. So if there is more data, print the next header for this group,
// else print the report-footer and finish the report processing.
if (advanceRequested && advanceable)
{
final DefaultFlowController cfc = fc.performCommit();
next.setFlowController(cfc);
next.setAdvanceHandler(BeginCrosstabHandler.HANDLER);
return next;
}
else
{
next.setAdvanceHandler(ReportFooterHandler.HANDLER);
return next;
}
}
if (advanceRequested == false || advanceable == false)
{
// This happens for empty - reports. Empty-Reports are never advanceable, therefore we can
// reach an non-advance state where inner group-footers are printed.
next.setAdvanceHandler(EndGroupBodyHandler.HANDLER);
return next;
}
// This group is not the outer-most group ..
final Group group = next.getReport().getGroup(next.getCurrentGroupIndex());
final DefaultFlowController cfc = fc.performCommit();
if (ProcessState.isLastItemInGroup(group, fc.getMasterRow(), cfc.getMasterRow()))
{
// continue with an other EndGroup-State ...
next.setAdvanceHandler(EndGroupBodyHandler.HANDLER);
return next;
}