public int getGroupCount()
{
int result = 1; // we always have at least a default-group.
Group existingGroup = rootGroup;
GroupBody gb = existingGroup.getBody();
while (gb != null)
{
final int count = gb.getElementCount();
boolean found = false;
for (int i = 0; i < count; i++)
{
final ReportElement element = gb.getElement(i);
if (element instanceof Group)
{
existingGroup = (Group) element;
result += 1;
gb = existingGroup.getBody();