private void copyParameters(JRCrosstab crosstab, JRBaseObjectFactory factory) {
    JRCrosstabParameter[] crossParameters = crosstab.getParameters();
    if (crossParameters != null) {
      parameters = new JRCrosstabParameter[crossParameters.length];
      for (int i = 0; i < parameters.length; i++) {
        parameters[i] = factory.getCrosstabParameter(crossParameters[i]);
      }
    }

    parametersMapExpression = factory.getExpression(crosstab.getParametersMapExpression());
  }
 private void copyMeasures(JRCrosstab crosstab, JRBaseObjectFactory factory) {
   JRCrosstabMeasure[] crossMeasures = crosstab.getMeasures();
   if (crossMeasures != null) {
     this.measures = new JRCrosstabMeasure[crossMeasures.length];
     for (int i = 0; i < crossMeasures.length; ++i) {
       this.measures[i] = factory.getCrosstabMeasure(crossMeasures[i]);
     }
   }
 }
 private void copyColumnGroups(JRCrosstab crosstab, JRBaseObjectFactory factory) {
   JRCrosstabColumnGroup[] crossColumnGroups = crosstab.getColumnGroups();
   if (crossColumnGroups != null) {
     this.columnGroups = new JRCrosstabColumnGroup[crossColumnGroups.length];
     for (int i = 0; i < crossColumnGroups.length; ++i) {
       this.columnGroups[i] = factory.getCrosstabColumnGroup(crossColumnGroups[i]);
     }
   }
 }
 private void copyVariables(JRCrosstab crosstab, JRBaseObjectFactory factory) {
   JRVariable[] vars = crosstab.getVariables();
   if (vars != null) {
     variables = new JRVariable[vars.length];
     for (int i = 0; i < vars.length; i++) {
       variables[i] = factory.getVariable(vars[i]);
     }
   }
 }
 private void copyCells(JRCrosstab crosstab, JRBaseObjectFactory factory) {
   JRCrosstabCell[][] crossCells = crosstab.getCells();
   if (crossCells != null) {
     this.cells = new JRCrosstabCell[rowGroups.length + 1][columnGroups.length + 1];
     for (int i = 0; i <= rowGroups.length; i++) {
       for (int j = 0; j <= columnGroups.length; ++j) {
         this.cells[i][j] = factory.getCrosstabCell(crossCells[i][j]);
       }
     }
   }
 }
  public JRBaseCrosstab(JRCrosstab crosstab, JRBaseObjectFactory factory, int id) {
    super(crosstab, factory);

    this.id = id;

    this.columnBreakOffset = crosstab.getColumnBreakOffset();
    this.repeatColumnHeaders = crosstab.isRepeatColumnHeaders();
    this.repeatRowHeaders = crosstab.isRepeatRowHeaders();
    this.runDirectionValue = crosstab.getRunDirectionValue();
    this.ignoreWidth = crosstab.getIgnoreWidth();

    this.dataset = factory.getCrosstabDataset(crosstab.getDataset());

    copyParameters(crosstab, factory);
    copyVariables(crosstab, factory);
    headerCell = factory.getCell(crosstab.getHeaderCell());
    copyRowGroups(crosstab, factory);
    copyColumnGroups(crosstab, factory);
    copyMeasures(crosstab, factory);
    copyCells(crosstab, factory);

    whenNoDataCell = factory.getCell(crosstab.getWhenNoDataCell());
  }
  public static JRElement getElementByKey(JRCrosstab crosstab, String key) {
    JRElement element = null;

    if (crosstab.getHeaderCell() != null) {
      element = crosstab.getHeaderCell().getElementByKey(key);
    }

    if (element == null) {
      element = getHeadersElement(crosstab.getRowGroups(), key);
    }

    if (element == null) {
      element = getHeadersElement(crosstab.getColumnGroups(), key);
    }

    if (element == null) {
      if (crosstab instanceof JRDesignCrosstab) {
        List cellsList = ((JRDesignCrosstab) crosstab).getCellsList();
        for (Iterator it = cellsList.iterator(); element == null && it.hasNext(); ) {
          JRCrosstabCell cell = (JRCrosstabCell) it.next();
          element = cell.getContents().getElementByKey(key);
        }
      } else {
        JRCrosstabCell[][] cells = crosstab.getCells();
        for (int i = cells.length - 1; element == null && i >= 0; --i) {
          for (int j = cells[i].length - 1; element == null && j >= 0; --j) {
            JRCrosstabCell cell = cells[i][j];
            if (cell != null) {
              element = cell.getContents().getElementByKey(key);
            }
          }
        }
      }
    }

    if (element == null && crosstab.getWhenNoDataCell() != null) {
      element = crosstab.getWhenNoDataCell().getElementByKey(key);
    }

    return element;
  }
 /**
  * Returns the name of the expression evaluator unit for a crosstab of a report.
  *
  * @param report the report
  * @param crosstab the crosstab
  * @return the generated expression evaluator unit name
  */
 public static String getUnitName(JasperReport report, JRCrosstab crosstab) {
   return getUnitName(report, crosstab.getId(), report.getCompileNameSuffix());
 }