/**
   * Receives notification that report generation has completed, the report footer was printed, no
   * more output is done. This is a helper event to shut down the output service.
   *
   * @param event The event.
   */
  public void reportDone(final ReportEvent event) {
    if (event.isDeepTraversing()) {
      return;
    }

    if (FunctionUtilities.isDefinedPrepareRunLevel(this, event)) {
      final Iterator iterator = dataStorage.entrySet().iterator();
      while (iterator.hasNext()) {
        final Map.Entry entry = (Map.Entry) iterator.next();
        final String key = (String) entry.getKey();
        final IndexDataHolder data = (IndexDataHolder) entry.getValue();
        model.addRow(
            new Object[] {
              data.getData(),
              data.getPagesText(indexSeparator, condensedStyle),
              data.getPages(),
              key
            });
      }
    } else if (FunctionUtilities.isLayoutLevel(event)) {
      final int rowCount = model.getRowCount();
      for (int i = 0; i < rowCount; i++) {
        final String key = (String) model.getValueAt(i, 3);
        final IndexDataHolder dataHolder = dataStorage.get(key);
        model.setValueAt(dataHolder.getPagesText(indexSeparator, condensedStyle), i, 1);
        model.setValueAt(dataHolder.getPages(), i, 2);
      }
    }
  }
  /**
   * Receives notification that a row of data is being processed.
   *
   * @param event the event.
   */
  public void itemsAdvanced(final ReportEvent event) {
    if (event.isDeepTraversing()) {
      if ("index".equals(event.getOriginatingState().getReport().getMetaData().getName())) {
        return;
      }
    }

    final Object o = computeDataValue(event);
    if (o == null) {
      return;
    }

    if (FunctionUtilities.isDefinedPrepareRunLevel(this, event)) {
      dataStorage.put(String.valueOf(o), new IndexDataHolder(o));
    } else if (FunctionUtilities.isLayoutLevel(event)) {
      final IndexDataHolder o1 = dataStorage.get(String.valueOf(o));
      if (o1 == null) {
        throw new IllegalStateException(
            "Unable to compute index: Function values changed between prepare and layout run");
      }
      o1.addPage(pageFunction.getPage());
    }
  }