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;
  }
  private JRVariable createHelperVariable(
      JRVariable variable, String nameSuffix, byte calculation) {
    JRDesignVariable helper = new JRDesignVariable();
    helper.setName(variable.getName() + nameSuffix);
    helper.setValueClassName(variable.getValueClassName());
    helper.setIncrementerFactoryClassName(variable.getIncrementerFactoryClassName());
    helper.setResetType(variable.getResetType());
    helper.setResetGroup(variable.getResetGroup());
    helper.setIncrementType(variable.getIncrementType());
    helper.setIncrementGroup(variable.getIncrementGroup());
    helper.setCalculation(calculation);
    helper.setSystemDefined(true);
    helper.setExpression(variable.getExpression());

    return helper;
  }
 /** @deprecated Replaced by {@link #setIncrementType(IncrementTypeEnum)} */
 public void setIncrementType(byte incrementType) {
   setIncrementType(IncrementTypeEnum.getByValue(incrementType));
 }