Java 类net.sf.jasperreports.engine.type.CalculationEnum 实例源码

项目:jasperreports    文件:BaseReturnValue.java   
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
{
    GetField fields = stream.readFields();
    fromVariable = (String) fields.get("fromVariable", null);

    // the fields of BaseCommonReturnValue were originally in this class.
    // if deserializing an old object, we need to manually copy the values into the parent class.
    ObjectStreamClass streamClass = fields.getObjectStreamClass();
    if (streamClass.getField("toVariable") != null)
    {
        this.toVariable = (String) fields.get("toVariable", null);
    }
    if (streamClass.getField("calculation") != null)
    {
        this.calculation = (CalculationEnum) fields.get("calculation", null);
    }
    if (streamClass.getField("incrementerFactoryClassName") != null)
    {
        this.incrementerFactoryClassName = (String) fields.get("incrementerFactoryClassName", null);
    }
}
项目:jasperreports    文件:JRVariableExpressionFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignVariable variable = (JRDesignVariable)digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    if (
        variable.getCalculationValue() == CalculationEnum.COUNT
        || variable.getCalculationValue() == CalculationEnum.DISTINCT_COUNT
        )
    {
        expression.setValueClassName(java.lang.Object.class.getName());
    }
    else
    {
        expression.setValueClassName(variable.getValueClassName());
    }

    return expression;
}
项目:jasperreports    文件:JRXmlWriter.java   
/**
 *
 */
private void writeVariable(JRVariable variable) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_variable);
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, variable.getName());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_class, variable.getValueClassName());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_resetType, variable.getResetTypeValue(), ResetTypeEnum.REPORT);
    if (variable.getResetGroup() != null)
    {
        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_resetGroup, variable.getResetGroup().getName());
    }
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementType, variable.getIncrementTypeValue(), IncrementTypeEnum.NONE);
    if (variable.getIncrementGroup() != null)
    {
        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_incrementGroup, variable.getIncrementGroup().getName());
    }
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation, variable.getCalculationValue(), CalculationEnum.NOTHING);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, variable.getIncrementerFactoryClassName());

    writeExpression(JRXmlConstants.ELEMENT_variableExpression, variable.getExpression(), false);
    writeExpression(JRXmlConstants.ELEMENT_initialValueExpression, variable.getInitialValueExpression(), false);

    writer.closeElement();
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 *
 */
private void writeVariable( JRVariable variable, String variableName)
{
    if(variable != null)
    {
        String resetGroupName = getGroupName( variable.getResetGroup());
        String incrementGroupName = getGroupName( variable.getIncrementGroup());

        write( "JRDesignVariable " + variableName + " = new JRDesignVariable();\n");
        write( variableName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(variable.getName()));
        write( variableName + ".setValueClassName(\"{0}\");\n", variable.getValueClassName());
        write( variableName + ".setResetType({0});\n", variable.getResetTypeValue(), ResetTypeEnum.REPORT);
        write( variableName + ".setResetGroup({0});\n", resetGroupName);
        write( variableName + ".setIncrementType({0});\n", variable.getIncrementTypeValue(), IncrementTypeEnum.NONE);
        write( variableName + ".setIncrementGroup({0});\n", incrementGroupName);

        write( variableName + ".setCalculation({0});\n", variable.getCalculationValue(), CalculationEnum.NOTHING);
        write( variableName + ".setIncrementerFactoryClass({0}.class);\n", JRStringUtil.escapeJavaStringLiteral(variable.getIncrementerFactoryClassName()));
        writeExpression( variable.getExpression(), variableName, "Expression");
        writeExpression( variable.getInitialValueExpression(), variableName, "InitialValueExpression");
        flush();
    }
}
项目:jasperreports    文件:JRApiWriter.java   
private void writeReturnValue(ReturnValue returnValue, String returnValueName)
{
    if(returnValue != null)
    {
        write("DesignReturnValue " + returnValueName + " = new DesignReturnValue();\n");
        write(returnValueName + ".setFromVariable(\"{0}\");\n", 
                JRStringUtil.escapeJavaStringLiteral(returnValue.getFromVariable()));
        write(returnValueName + ".setToVariable(\"{0}\");\n", 
                JRStringUtil.escapeJavaStringLiteral(returnValue.getToVariable()));
        write(returnValueName + ".setCalculation({0});\n", 
                returnValue.getCalculation(), CalculationEnum.NOTHING);
        write(returnValueName + ".setIncrementerFactoryClassName(\"{0}\");\n", 
                JRStringUtil.escapeJavaStringLiteral(returnValue.getIncrementerFactoryClassName()));
        flush();
    }
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 * 
 */
protected void writeCrosstabMeasure( JRCrosstabMeasure measure, String measureName)
{
    if(measure != null)
    {
        write( "JRDesignCrosstabMeasure " + measureName + " = new JRDesignCrosstabMeasure();\n");
        write( measureName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(measure.getName()));

        write( measureName + ".setValueClassName(\"{0}\");\n", measure.getValueClassName());

        write( measureName + ".setCalculation({0});\n", measure.getCalculationValue(), CalculationEnum.NOTHING);
        write( measureName + ".setPercentageType({0});\n", measure.getPercentageType(), CrosstabPercentageEnum.NONE);
        write( measureName + ".setPercentageCalculatorClassName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(measure.getPercentageCalculatorClassName()));

        writeExpression( measure.getValueExpression(), measureName, "ValueExpression");

        flush();
    }
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createPageCountVariable()
{
    JRDesignExpression expression;
    JRDesignVariable variable;
    variable = new JRDesignVariable();
    variable.setName(JRVariable.PAGE_COUNT);
    variable.setValueClass(Integer.class);
    variable.setResetType(ResetTypeEnum.PAGE);
    variable.setCalculation(CalculationEnum.COUNT);
    variable.setSystemDefined(true);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(1)");
    variable.setExpression(expression);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(0)");
    variable.setInitialValueExpression(expression);
    return variable;
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createColumnNumberVariable()
{
    JRDesignExpression expression;
    JRDesignVariable variable;
    variable = new JRDesignVariable();
    variable.setName(JRVariable.COLUMN_NUMBER);
    variable.setValueClass(Integer.class);
    //variable.setResetType(JRVariable.RESET_TYPE_COLUMN);
    variable.setResetType(ResetTypeEnum.PAGE);
    variable.setCalculation(CalculationEnum.SYSTEM);
    variable.setSystemDefined(true);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    //expression.setText("($V{COLUMN_NUMBER} != null)?(Integer.valueOf($V{COLUMN_NUMBER}.intValue() + 1)):(Integer.valueOf(1))");
    expression.setText("new java.lang.Integer(1)");
    variable.setInitialValueExpression(expression);
    return variable;
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createPageNumberVariable()
{
    JRDesignVariable variable = new JRDesignVariable();
    variable.setName(JRVariable.PAGE_NUMBER);
    variable.setValueClass(Integer.class);
    //variable.setResetType(JRVariable.RESET_TYPE_PAGE);
    variable.setResetType(ResetTypeEnum.REPORT);
    variable.setCalculation(CalculationEnum.SYSTEM);
    variable.setSystemDefined(true);
    JRDesignExpression expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    //expression.setText("($V{PAGE_NUMBER} != null)?(Integer.valueOf($V{PAGE_NUMBER}.intValue() + 1)):(Integer.valueOf(1))");
    expression.setText("new java.lang.Integer(1)");
    variable.setInitialValueExpression(expression);
    return variable;
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createColumnCountVariable()
{
    JRDesignVariable variable;
    JRDesignExpression expression;
    variable = new JRDesignVariable();
    variable.setName(JRVariable.COLUMN_COUNT);
    variable.setValueClass(Integer.class);
    variable.setResetType(ResetTypeEnum.COLUMN);
    variable.setCalculation(CalculationEnum.COUNT);
    variable.setSystemDefined(true);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(1)");
    variable.setExpression(expression);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(0)");
    variable.setInitialValueExpression(expression);
    return variable;
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createReportCountVariable()
{
    JRDesignVariable variable = new JRDesignVariable();
    variable.setName(JRVariable.REPORT_COUNT);
    variable.setValueClass(Integer.class);
    variable.setResetType(ResetTypeEnum.REPORT);
    variable.setCalculation(CalculationEnum.COUNT);
    variable.setSystemDefined(true);
    JRDesignExpression expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(1)");
    variable.setExpression(expression);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(0)");
    variable.setInitialValueExpression(expression);
    return variable;
}
项目:jasperreports    文件:JRFillDataset.java   
private JRVariable createHelperVariable(JRVariable variable, String nameSuffix, CalculationEnum calculation)
{
    JRDesignVariable helper = new JRDesignVariable();
    helper.setName(variable.getName() + nameSuffix);
    helper.setValueClassName(variable.getValueClassName());
    helper.setIncrementerFactoryClassName(variable.getIncrementerFactoryClassName());
    helper.setResetType(variable.getResetTypeValue());
    helper.setResetGroup(variable.getResetGroup());
    helper.setIncrementType(variable.getIncrementTypeValue());
    helper.setIncrementGroup(variable.getIncrementGroup());
    helper.setCalculation(calculation);
    helper.setSystemDefined(true);
    helper.setExpression(variable.getExpression());

    return helper;
}
项目:jasperreports    文件:JRFillDataset.java   
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(ResetTypeEnum.REPORT);

    if (variable.getIncrementTypeValue() != IncrementTypeEnum.NONE)
    {
        helper.setResetType(ResetTypeEnum.getByValue(variable.getIncrementTypeValue().getValue()));
    }
    helper.setResetGroup(variable.getIncrementGroup());
    helper.setCalculation(CalculationEnum.NOTHING);
    helper.setSystemDefined(true);
    helper.setExpression(variable.getExpression());

    return helper;
}
项目:jasperreports    文件:JRCrosstabMeasureExpressionFactory.java   
@Override
public Object createObject(Attributes attributes)
{
    JRDesignCrosstabMeasure measure = (JRDesignCrosstabMeasure) digester.peek();

    JRDesignExpression expression = new JRDesignExpression();
    if (
        measure.getCalculationValue() == CalculationEnum.COUNT
        || measure.getCalculationValue() == CalculationEnum.DISTINCT_COUNT
        )
    {
        expression.setValueClassName(Object.class.getName());
    }
    else
    {
        expression.setValueClassName(measure.getValueClassName());
    }

    return expression;
}
项目:PDFReporter-Studio    文件:MMeasure.java   
public void setPropertyValue(Object id, Object value) {
    JRDesignCrosstabMeasure jrField = (JRDesignCrosstabMeasure) getValue();
    if (id.equals(JRDesignCrosstabMeasure.PROPERTY_NAME))
        jrField.setName((String) value);
    else if (id.equals(JRDesignCrosstabMeasure.PROPERTY_CALCULATION))
        jrField.setCalculation((CalculationEnum) calculationD
                .getEnumValue(value));
    else if (id.equals(JRDesignCrosstabMeasure.PROPERTY_PERCENTAGE_OF_TYPE))
        jrField.setPercentageType((CrosstabPercentageEnum) percentOfTypeD
                .getEnumValue(value));
    else if (id.equals(JRDesignCrosstabMeasure.PROPERTY_VALUE_EXPRESSION))
        jrField.setValueExpression(ExprUtil.setValues(
                jrField.getValueExpression(), value));
    else if (id.equals(JRDesignCrosstabMeasure.PROPERTY_VALUE_CLASS))
        jrField.setValueClassName((String) value);
    else if (id
            .equals(JRDesignCrosstabMeasure.PROPERTY_INCREMENTER_FACTORY_CLASS_NAME))
        jrField.setIncrementerFactoryClassName((String) value);
    else if (id
            .equals(JRDesignCrosstabMeasure.PROPERTY_PERCENTAGE_CALCULATION_CLASS_NAME))
        jrField.setPercentageCalculatorClassName((String) value);
}
项目:PDFReporter-Studio    文件:CreatePercentageCommand.java   
private JRDesignVariable createVariable(String name, String clazz, ResetTypeEnum rtype, JRGroup group)
        throws Exception {
    jrVariable = new JRDesignVariable();
    jrVariable.setCalculation(CalculationEnum.SUM);

    String vname = name + "_SUM";
    int i=0;
    while (jasperDesign.getVariablesMap().containsKey(vname))
    {
        i++;
        vname = name + "_" + i + "_SUM";
    }

    jrVariable.setName(vname);
    jrVariable.setResetType(rtype);
    if (rtype.equals(ResetTypeEnum.GROUP))
        jrVariable.setResetGroup(group);

    jrVariable.setValueClassName(clazz);

    JRDesignExpression jre = new JRDesignExpression();
    jre.setText("$F{" + name + "}");
    jrVariable.setExpression(jre);

    return jrVariable;
}
项目:ireport-fork    文件:VariableNode.java   
@Override
@SuppressWarnings("unchecked")
public PropertyEditor getPropertyEditor() {

    if (editor == null)
    {
        java.util.ArrayList l = new java.util.ArrayList();

        l.add(new Tag(CalculationEnum.NOTHING, I18n.getString("VariableNode.Property.Nothing")));
        l.add(new Tag(CalculationEnum.COUNT, I18n.getString("VariableNode.Property.Count")));
        l.add(new Tag(CalculationEnum.DISTINCT_COUNT, I18n.getString("VariableNode.Property.DistinctCount")));
        l.add(new Tag(CalculationEnum.SUM, I18n.getString("VariableNode.Property.Sum")));
        l.add(new Tag(CalculationEnum.AVERAGE, I18n.getString("VariableNode.Property.Average")));
        l.add(new Tag(CalculationEnum.LOWEST, I18n.getString("VariableNode.Property.Lowest")));
        l.add(new Tag(CalculationEnum.HIGHEST, I18n.getString("VariableNode.Property.Highest")));
        l.add(new Tag(CalculationEnum.STANDARD_DEVIATION, I18n.getString("VariableNode.Property.StandardDeviation")));
        l.add(new Tag(CalculationEnum.VARIANCE, I18n.getString("VariableNode.Property.Variance")));
        l.add(new Tag(CalculationEnum.SYSTEM, I18n.getString("VariableNode.Property.System")));
        l.add(new Tag(CalculationEnum.FIRST, I18n.getString("VariableNode.Property.First")));

        editor = new ComboBoxPropertyEditor(false, l);
    }
    return editor;
}
项目:ireport-fork    文件:VariableNode.java   
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    if (val instanceof CalculationEnum)
    {
        CalculationEnum oldValue = variable.getCalculationValue();
        CalculationEnum newValue = (CalculationEnum)val;
        variable.setCalculation(newValue);

        ObjectPropertyUndoableEdit urob =
                new ObjectPropertyUndoableEdit(
                    variable,
                    "Calculation", 
                    CalculationEnum.class,
                    oldValue,newValue);
        // Find the undoRedo manager...
        IReportManager.getInstance().addUndoableEdit(urob);
    }
}
项目:ireport-fork    文件:CrosstabMeasureNode.java   
@Override
public List getTagList()
{
    List tags = new java.util.ArrayList();
        tags.add(new Tag(CalculationEnum.NOTHING, "Nothing"));
        tags.add(new Tag(CalculationEnum.COUNT, "Count"));
        tags.add(new Tag(CalculationEnum.DISTINCT_COUNT, "Distinct Count"));
        tags.add(new Tag(CalculationEnum.SUM, "Sum"));
        tags.add(new Tag(CalculationEnum.AVERAGE, "Average"));
        tags.add(new Tag(CalculationEnum.LOWEST, "Lowest"));
        tags.add(new Tag(CalculationEnum.HIGHEST, "Highest"));
        tags.add(new Tag(CalculationEnum.STANDARD_DEVIATION, "Standard Deviation"));
        tags.add(new Tag(CalculationEnum.VARIANCE, "Variance"));
        tags.add(new Tag(CalculationEnum.FIRST, "First"));
        return tags;
}
项目:ireport-fork    文件:CrosstabVisualPanel4.java   
public JRDesignCrosstabMeasure getMeasure()
{
    JRDesignCrosstabMeasure measure = new JRDesignCrosstabMeasure();
    measure.setName( groupPanel1.getGroupMeasureName()+I18n.getString("CrosstabVisualPanel4.Label.Measure") );
    measure.setValueExpression( groupPanel1.getDesignExpression() );
    measure.setCalculation( groupPanel1.getCalculationType() );
    measure.setValueClassName( groupPanel1.getDesignExpression().getValueClassName() );
    if (groupPanel1.getCalculationType() == CalculationEnum.COUNT)
    {
        measure.setValueClassName( "java.lang.Integer");
    }
    else
    {
        measure.setValueClassName( measure.getValueExpression().getValueClassName() );
    }

    return measure;
}
项目:ireport-fork    文件:VariableExpressionProperty.java   
@Override
public void setExpression(JRDesignExpression expression)
{
    // This avoid incompatibilities with the
    // variable...
    if (expression != null)
    {
        if (variable.getCalculationValue() == CalculationEnum.COUNT ||
            variable.getCalculationValue() == CalculationEnum.DISTINCT_COUNT)
        {
            expression.setValueClassName("java.lang.Object");
        }
        else
        {
            expression.setValueClassName(variable.getValueClassName());
        }
    }
    variable.setExpression(expression);
}
项目:ireport-fork    文件:JRSubreportReturnValueDialog.java   
/**
 * DOCUMENT ME!
 */
public void setTypes()
{
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.NOTHING,I18n.getString("JRSubreportReturnValueDialog.ComboBox.Nothing")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.COUNT, I18n.getString("JRSubreportReturnValueDialog.ComboBox.Count")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.DISTINCT_COUNT, I18n.getString("JRSubreportReturnValueDialog.ComboBox.DistinctCount")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.SUM, I18n.getString("JRSubreportReturnValueDialog.ComboBox.Sum")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.AVERAGE, I18n.getString("JRSubreportReturnValueDialog.ComboBox.Average")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.LOWEST, I18n.getString("JRSubreportReturnValueDialog.ComboBox.Lowest")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.HIGHEST, I18n.getString("JRSubreportReturnValueDialog.ComboBox.Highest")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.STANDARD_DEVIATION, I18n.getString("JRSubreportReturnValueDialog.ComboBox.StandardDeviation")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.VARIANCE, I18n.getString("JRSubreportReturnValueDialog.ComboBox.Variance")));
    // CALCULATION_SYSTEM Not allowed as calc type for return values... [bug 0004349]
    // this.jComboBoxCalculationType.addItem(new Tag( new Byte( JRDesignVariable.CALCULATION_SYSTEM ), I18n.getString("JRSubreportReturnValueDialog.ComboBox.System")));
    this.jComboBoxCalculationType.addItem(new Tag( CalculationEnum.FIRST, I18n.getString("JRSubreportReturnValueDialog.ComboBox.First")));
}
项目:ireport-fork    文件:AggregationFunctionDialog.java   
public void setFunctionSet(int set)
{
    jComboBox1.removeAllItems();

    jComboBox1.addItem(new Tag(CalculationEnum.COUNT, I18n.getString("VariableNode.Property.Count")));
    jComboBox1.addItem(new Tag(CalculationEnum.DISTINCT_COUNT, I18n.getString("VariableNode.Property.DistinctCount")));

    jComboBox1.setSelectedIndex(0);

    if (set == NUMERIC_SET)
    {
        //jComboBox1.addItem(new Tag(new Byte(JRDesignVariable.CALCULATION_NOTHING), I18n.getString("VariableNode.Property.Nothing")));
        jComboBox1.addItem(new Tag(CalculationEnum.SUM, I18n.getString("VariableNode.Property.Sum")));
        jComboBox1.addItem(new Tag(CalculationEnum.AVERAGE, I18n.getString("VariableNode.Property.Average")));
        jComboBox1.addItem(new Tag(CalculationEnum.LOWEST, I18n.getString("VariableNode.Property.Lowest")));
        jComboBox1.addItem(new Tag(CalculationEnum.HIGHEST, I18n.getString("VariableNode.Property.Highest")));
        jComboBox1.addItem(new Tag(CalculationEnum.STANDARD_DEVIATION, I18n.getString("VariableNode.Property.StandardDeviation")));
        jComboBox1.addItem(new Tag(CalculationEnum.VARIANCE, I18n.getString("VariableNode.Property.Variance")));
        jComboBox1.addItem(new Tag(CalculationEnum.SYSTEM, I18n.getString("VariableNode.Property.System")));
        jComboBox1.addItem(new Tag(CalculationEnum.FIRST, I18n.getString("VariableNode.Property.First")));
        setSelectedFunction(CalculationEnum.SUM);
    }

}
项目:ireport-fork    文件:AggregationFunctionDialog.java   
public void setSelectedFunction(String function)
{
    if (function == null) return;
    if (function.equals("Count")) setSelectedFunction( CalculationEnum.COUNT );
    if (function.equals("DistinctCount")) setSelectedFunction(CalculationEnum.DISTINCT_COUNT);
    if (function.equals("Sum")) setSelectedFunction(CalculationEnum.SUM);
    if (function.equals("Average")) setSelectedFunction(CalculationEnum.AVERAGE);
    if (function.equals("Lowest")) setSelectedFunction(CalculationEnum.LOWEST);
    if (function.equals("Highest")) setSelectedFunction(CalculationEnum.HIGHEST);
    if (function.equals("standardDeviation")) setSelectedFunction(CalculationEnum.STANDARD_DEVIATION);
    if (function.equals("variance")) setSelectedFunction(CalculationEnum.VARIANCE);
    if (function.equals("first")) setSelectedFunction(CalculationEnum.FIRST);

    // No function found...
    return;
}
项目:jasperreports    文件:JRBaseSubreportReturnValue.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        calculationValue = CalculationEnum.getByValue(calculation);
    }

}
项目:jasperreports    文件:JRBaseVariable.java   
@SuppressWarnings("deprecation")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
    in.defaultReadObject();

    if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2)
    {
        resetTypeValue = ResetTypeEnum.getByValue(resetType);
        incrementTypeValue = IncrementTypeEnum.getByValue(incrementType);
        calculationValue = CalculationEnum.getByValue(calculation);
    }

}
项目:jasperreports    文件:JRSubreportReturnValueFactory.java   
/**
 * Creates an object from a subreport copied value XML element.
 * 
 * @param atts the element attributes
 * @return a {@link JRDesignSubreportReturnValue JRDesignSubreportReturnValue} object
 */
@Override
public Object createObject(Attributes atts)
{
    JRXmlLoader xmlLoader = (JRXmlLoader) digester.peek(digester.getCount() - 1);
    JasperDesign design = (JasperDesign) digester.peek(digester.getCount() - 2);

    JRDesignSubreportReturnValue returnValue = new JRDesignSubreportReturnValue();

    String variableName = atts.getValue(JRXmlConstants.ATTRIBUTE_toVariable);
    JRVariable variable = design.getVariablesMap().get(variableName);
    if (variable == null)
    {
        xmlLoader.addError(new JRValidationException("Unknown variable " + variableName, returnValue));
    }

    returnValue.setSubreportVariable(atts.getValue(JRXmlConstants.ATTRIBUTE_subreportVariable));
    returnValue.setToVariable(variableName);

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

    String incrementerFactoryClass = atts.getValue(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass);
    if (incrementerFactoryClass != null)
    {
        returnValue.setIncrementerFactoryClassName(incrementerFactoryClass);
    }

    return returnValue;
}
项目:jasperreports    文件:JRXmlDigesterFactory.java   
private static void addDatasetRules(Digester digester)
{
    String subDatasetPattern = "jasperReport/" + JRXmlConstants.ELEMENT_subDataset;
    digester.addFactoryCreate(subDatasetPattern, JRDatasetFactory.class.getName());
    digester.addSetNext(subDatasetPattern, "addDataset", JRDesignDataset.class.getName());

    String datasetRunPattern = "*/" + JRXmlConstants.ELEMENT_datasetRun;
    digester.addFactoryCreate(datasetRunPattern, JRDatasetRunFactory.class.getName());
    digester.addSetNext(datasetRunPattern, "setDatasetRun", JRDatasetRun.class.getName());

    String datasetParamPattern = datasetRunPattern + "/" + JRXmlConstants.ELEMENT_datasetParameter;
    digester.addFactoryCreate(datasetParamPattern, JRDatasetRunParameterFactory.class.getName());
    digester.addSetNext(datasetParamPattern, "addParameter", JRDatasetParameter.class.getName());

    String datasetParamExprPattern = datasetParamPattern + "/" + JRXmlConstants.ELEMENT_datasetParameterExpression;
    digester.addFactoryCreate(datasetParamExprPattern, JRExpressionFactory.class.getName());
    digester.addSetNext(datasetParamExprPattern, "setExpression", JRExpression.class.getName());
    digester.addCallMethod(datasetParamExprPattern, "setText", 0);

    String returnValuePattern = datasetRunPattern + "/" + JRXmlConstants.ELEMENT_returnValue;
    digester.addObjectCreate(returnValuePattern, DesignReturnValue.class.getName());
    digester.addSetProperties(returnValuePattern, 
            new String[]{JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, JRXmlConstants.ATTRIBUTE_calculation}, 
            new String[]{"incrementerFactoryClassName"});
    digester.addRule(returnValuePattern, new XmlConstantPropertyRule(
            JRXmlConstants.ATTRIBUTE_calculation, CalculationEnum.values()));
    digester.addSetNext(returnValuePattern, "addReturnValue");
}
项目:jasperreports    文件:ExpressionReturnValueFactory.java   
/**
 * @param atts the element attributes
 * @return a {@link DesignExpressionReturnValue DesignExpressionReturnValue} object
 */
@Override
public Object createObject(Attributes atts)
{
    JRXmlLoader xmlLoader = (JRXmlLoader) digester.peek(digester.getCount() - 1);
    JasperDesign design = (JasperDesign) digester.peek(digester.getCount() - 2);

    DesignExpressionReturnValue returnValue = new DesignExpressionReturnValue();

    String variableName = atts.getValue(JRXmlConstants.ATTRIBUTE_toVariable);
    JRVariable variable = design.getVariablesMap().get(variableName);
    if (variable == null)
    {
        xmlLoader.addError(new JRValidationException("Unknown variable " + variableName, returnValue));
    }

    returnValue.setToVariable(variableName);

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

    String incrementerFactoryClass = atts.getValue(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass);
    if (incrementerFactoryClass != null)
    {
        returnValue.setIncrementerFactoryClassName(incrementerFactoryClass);
    }

    return returnValue;
}
项目:jasperreports    文件:JRXmlWriter.java   
public void writeSubreportReturnValue(JRSubreportReturnValue returnValue, XmlNamespace namespace) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_returnValue, namespace);
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_subreportVariable, returnValue.getFromVariable());
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_toVariable, returnValue.getToVariable());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation, returnValue.getCalculation(), CalculationEnum.NOTHING);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, returnValue.getIncrementerFactoryClassName());
    writer.closeElement();
}
项目:jasperreports    文件:JRXmlWriter.java   
protected void writeReturnValue(VariableReturnValue returnValue) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_returnValue);
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_fromVariable, returnValue.getFromVariable());
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_toVariable, returnValue.getToVariable());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation, returnValue.getCalculation(), CalculationEnum.NOTHING);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, returnValue.getIncrementerFactoryClassName());
    writer.closeElement();
}
项目:jasperreports    文件:JRXmlWriter.java   
protected void writeReturnValue(ExpressionReturnValue returnValue) throws IOException
{
    writer.startElement(JRXmlConstants.ELEMENT_returnValue);
    writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_toVariable, returnValue.getToVariable());
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_calculation, returnValue.getCalculation(), CalculationEnum.NOTHING);
    writer.addAttribute(JRXmlConstants.ATTRIBUTE_incrementerFactoryClass, returnValue.getIncrementerFactoryClassName());
    writeExpression(JRXmlConstants.ELEMENT_expression, returnValue.getExpression(), false);
    writer.closeElement();
}
项目:jasperreports    文件:JRXmlWriter.java   
protected void writeCrosstabMeasure(JRCrosstabMeasure measure) throws IOException
{
    writer.startElement(JRCrosstabMeasureFactory.ELEMENT_measure);
    writer.addEncodedAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_name, measure.getName());
    writer.addAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_class, measure.getValueClassName());
    writer.addAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_calculation, measure.getCalculationValue(), CalculationEnum.NOTHING);
    writer.addAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_incrementerFactoryClass, measure.getIncrementerFactoryClassName());
    writer.addAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_percentageOf, measure.getPercentageType(), CrosstabPercentageEnum.NONE);
    writer.addAttribute(JRCrosstabMeasureFactory.ATTRIBUTE_percentageCalculatorClass, measure.getPercentageCalculatorClassName());
    writeExpression(JRCrosstabMeasureFactory.ELEMENT_measureExpression, measure.getValueExpression(), false);

    writer.closeElement();
}
项目:jasperreports    文件:JRApiWriter.java   
/**
 * 
 */
private void writeSubreportReturnValue(JRSubreportReturnValue returnValue, String returnValueName)
{
    if(returnValue != null)
    {
        write( "JRDesignSubreportReturnValue " + returnValueName + " = new JRDesignSubreportReturnValue();\n");
        write( returnValueName + ".setSubreportVariable(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(returnValue.getFromVariable()));
        write( returnValueName + ".setToVariable(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(returnValue.getToVariable()));
        write( returnValueName + ".setCalculation({0});\n", returnValue.getCalculation(), CalculationEnum.NOTHING);
        write( returnValueName + ".setIncrementerFactoryClassName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(returnValue.getIncrementerFactoryClassName()));
        flush();
    }
}
项目:jasperreports    文件:JRApiWriter.java   
private void writeReturnValue(ExpressionReturnValue returnValue, String returnValueName)
{
    if(returnValue != null)
    {
        write("DesignExpressionReturnValue " + returnValueName + " = new DesignExpressionReturnValue();\n");
        writeExpression( returnValue.getExpression(), returnValueName, "Expression");
        write(returnValueName + ".setToVariable(\"{0}\");\n", 
                JRStringUtil.escapeJavaStringLiteral(returnValue.getToVariable()));
        write(returnValueName + ".setCalculation({0});\n", 
                returnValue.getCalculation(), CalculationEnum.NOTHING);
        write(returnValueName + ".setIncrementerFactoryClassName(\"{0}\");\n", 
                JRStringUtil.escapeJavaStringLiteral(returnValue.getIncrementerFactoryClassName()));
        flush();
    }
}
项目:jasperreports    文件:JRDesignSubreportReturnValue.java   
/**
 * Sets the calculation type.
 * 
 * @param calculationValue the calculation type
 * @see net.sf.jasperreports.engine.JRSubreportReturnValue#getCalculation()
 */
public void setCalculation(CalculationEnum calculationValue)
{
    CalculationEnum old = this.calculationValue;
    this.calculationValue = calculationValue;
    getEventSupport().firePropertyChange(PROPERTY_CALCULATION, old, this.calculationValue);
}
项目:jasperreports    文件:JRDesignVariable.java   
/**
 *
 */
public void setCalculation(CalculationEnum calculationValue)
{
    CalculationEnum old = this.calculationValue;
    this.calculationValue = calculationValue;
    getEventSupport().firePropertyChange(PROPERTY_CALCULATION, old, this.calculationValue);
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createMasterCurrentPageVariable()
{
    JRDesignVariable variable = new JRDesignVariable();
    variable.setName(JRVariable.MASTER_CURRENT_PAGE);
    variable.setValueClass(Integer.class);
    variable.setResetType(ResetTypeEnum.REPORT);
    variable.setCalculation(CalculationEnum.SYSTEM);
    variable.setSystemDefined(true);
    return variable;
}
项目:jasperreports    文件:JRDesignDataset.java   
private static JRDesignVariable createMasterTotalPagesVariable()
{
    JRDesignVariable variable = new JRDesignVariable();
    variable.setName(JRVariable.MASTER_TOTAL_PAGES);
    variable.setValueClass(Integer.class);
    variable.setResetType(ResetTypeEnum.REPORT);
    variable.setCalculation(CalculationEnum.SYSTEM);
    variable.setSystemDefined(true);
    return variable;
}
项目:jasperreports    文件:JRDesignDataset.java   
/**
 * Inserts a group at the specified position into the dataset.
 * @param index the group position
 * @param group the group to insert
 * @throws JRException
 * @see net.sf.jasperreports.engine.JRDataset#getGroups()
 */
public void addGroup(int index, JRDesignGroup group) throws JRException
{
    if (groupsMap.containsKey(group.getName()))
    {
        throw 
            new JRException(
                EXCEPTION_MESSAGE_KEY_DUPLICATE_GROUP,
                new Object[]{group.getName()});
    }

    JRDesignVariable countVariable = new JRDesignVariable();
    countVariable.setName(group.getName() + "_COUNT");
    countVariable.setValueClass(Integer.class);
    countVariable.setResetType(ResetTypeEnum.GROUP);
    countVariable.setResetGroup(group);
    countVariable.setCalculation(CalculationEnum.COUNT);
    countVariable.setSystemDefined(true);
    JRDesignExpression expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(1)");
    countVariable.setExpression(expression);
    expression = new JRDesignExpression();
    //expression.setValueClass(Integer.class);
    expression.setText("new java.lang.Integer(0)");
    countVariable.setInitialValueExpression(expression);

    addVariable(countVariable, true);

    group.setCountVariable(countVariable);

    groupsList.add(index, group);
    groupsMap.put(group.getName(), group);

    getEventSupport().fireCollectionElementAddedEvent(PROPERTY_GROUPS, group, index);
}