public Object createObject(Attributes atts) {
    JRDesignVariable variable = new JRDesignVariable();

    variable.setName(atts.getValue(JRXmlConstants.ATTRIBUTE_name));

    if (atts.getValue(JRXmlConstants.ATTRIBUTE_class) != null) {
      variable.setValueClassName(atts.getValue(JRXmlConstants.ATTRIBUTE_class));
    }

    ResetTypeEnum resetType =
        ResetTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_resetType));
    if (resetType != null) {
      variable.setResetType(resetType);
    }

    String groupName = atts.getValue(JRXmlConstants.ATTRIBUTE_resetGroup);
    if (groupName != null) {
      JRDesignGroup group = new JRDesignGroup();
      group.setName(groupName);
      variable.setResetGroup(group);
    }

    IncrementTypeEnum incrementType =
        IncrementTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_incrementType));
    if (incrementType != null) {
      variable.setIncrementType(incrementType);
    }

    groupName = atts.getValue(JRXmlConstants.ATTRIBUTE_incrementGroup);
    if (groupName != null) {
      JRDesignGroup group = new JRDesignGroup();
      group.setName(groupName);
      variable.setIncrementGroup(group);
    }

    CalculationEnum calculation =
        CalculationEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_calculation));
    if (calculation != null) {
      variable.setCalculation(calculation);
    }

    if (atts.getValue(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass) != null) {
      variable.setIncrementerFactoryClassName(
          atts.getValue(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass));
    }

    return variable;
  }
  protected Object transformEntity(Entity entity) {

    DJGroupVariable groupVariable = (DJGroupVariable) entity;
    AbstractColumn col = groupVariable.getColumnToApplyOperation();

    String variableName = groupVariable.getName();
    log.debug("transforming group variable " + variableName);
    DJCalculation op = groupVariable.getOperation();

    JRDesignExpression expression = new JRDesignExpression();

    // only variables from the last registered group are important now
    List groupsList = getDjd().getGroupsList();
    JRDesignGroup registeredGroup = (JRDesignGroup) groupsList.get(groupsList.size() - 1);

    if (col instanceof ExpressionColumn
        && ((ExpressionColumn) col).getExpressionForCalculation() != null) {
      ExpressionColumn expcol = (ExpressionColumn) col;
      expression.setText(expcol.getTextForExpressionForCalculartion());
      expression.setValueClassName(expcol.getExpressionForCalculation().getClassName());
    } else if (col instanceof PercentageColumn) {
      PercentageColumn pcol = (PercentageColumn) col;
      expression.setText(pcol.getPercentageColumn().getTextForExpression());
      expression.setValueClassName(pcol.getPercentageColumn().getValueClassNameForExpression());

      DJGroup djgroup = groupVariable.getGroup();
      registeredGroup =
          LayoutUtils.findParentJRGroup(djgroup, getDynamicReport(), getDjd(), getLayoutManager());
    } else {
      if (col.getTextFormatter() != null) {
        PropertyColumn pcol = (PropertyColumn) col;
        expression.setText("$F{" + pcol.getColumnProperty().getProperty() + "}");
        expression.setValueClassName(pcol.getColumnProperty().getValueClassName());
      } else {
        expression.setText(col.getTextForExpression());
        expression.setValueClassName(col.getValueClassNameForExpression());
      }
    }

    JRDesignVariable variable = new JRDesignVariable();
    variable.setExpression(expression);
    variable.setCalculation(CalculationEnum.getByValue(groupVariable.getOperation().getValue()));
    variable.setName(variableName);

    variable.setResetType(ResetTypeEnum.GROUP);
    variable.setResetGroup(registeredGroup);

    String valueClassName = col.getVariableClassName(op);
    String initialExpression = col.getInitialExpression(op);

    //		if (DJCalculation.SYSTEM.equals(groupVariable.getOperation())){
    //			variable.setValueClassName(Object.class.getName());
    //		} else {
    //		}
    variable.setValueClassName(valueClassName);

    if (initialExpression != null) {
      JRDesignExpression initialExp = new JRDesignExpression();
      initialExp.setText(initialExpression);
      initialExp.setValueClassName(valueClassName);
      variable.setInitialValueExpression(initialExp);
    }

    return variable;
  }
 /** @deprecated Replaced by {@link #setCalculation(CalculationEnum)} */
 public void setCalculation(byte calculation) {
   setCalculation(CalculationEnum.getByValue(calculation));
 }