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;
  }
Пример #2
0
  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;
  }
Пример #3
0
  private JRVariable createDistinctCountHelperVariable(JRVariable variable) {
    JRDesignVariable helper = new JRDesignVariable();
    helper.setName(variable.getName() + "_DISTINCT_COUNT");
    helper.setValueClassName(variable.getValueClassName());
    helper.setIncrementerFactoryClassName(JRDistinctCountIncrementerFactory.class.getName());
    helper.setResetType(JRVariable.RESET_TYPE_REPORT);

    if (variable.getIncrementType() != JRVariable.RESET_TYPE_NONE)
      helper.setResetType(variable.getIncrementType());

    helper.setResetGroup(variable.getIncrementGroup());
    helper.setCalculation(JRVariable.CALCULATION_NOTHING);
    helper.setSystemDefined(true);
    helper.setExpression(variable.getExpression());

    return helper;
  }
 public void setIncrementerFactoryClass(Class clazz) {
   setIncrementerFactoryClassName(clazz.getName());
 }