Class TotalGroupSumQuotientFunction

  • All Implemented Interfaces:
    Serializable, Cloneable, EventListener, ReportListener, Expression, Function
    Direct Known Subclasses:
    TotalGroupSumQuotientPercentFunction

    public class TotalGroupSumQuotientFunction
    extends AbstractFunction
    A report function that calculates the quotient of two summed fields (columns) from the report's data row. This function produces a global total. The total sum of the group is known when the group processing starts and the report is not performing a prepare-run. The sum is calculated in the prepare run and recalled in the printing run.

    The function can be used in two ways:

    • to calculate a quotient for the entire report;
    • to calculate a quotient within a particular group;
    This function expects its input values to be either java.lang.Number instances or Strings that can be parsed to java.lang.Number instances using a java.text.DecimalFormat.

    The function undestands tree parameters. The dividend parameter is required and denotes the name of an ItemBand-field which gets summed up as dividend. The divisor parameter is required and denotes the name of an ItemBand-field which gets summed up as divisor.

    The parameter group denotes the name of a group. When this group is started, the counter gets reseted to null. This parameter is optional.

    Author:
    Thomas Morgner
    See Also:
    Serialized Form
    • Constructor Detail

      • TotalGroupSumQuotientFunction

        public TotalGroupSumQuotientFunction()
        Constructs a new function.

        Initially the function has no name...be sure to assign one before using the function.

    • Method Detail

      • getGroup

        public String getGroup()
        Returns the name of the group to be totalled.
        Returns:
        the group name.
      • setGroup

        public void setGroup​(String group)
        Defines the name of the group to be totalled. If the name is null, all groups are totalled.
        Parameters:
        group - the group name.
      • getValue

        public Object getValue()
        Return the current function value.

        The value depends (obviously) on the function implementation. For example, a page counting function will return the current page number.

        Returns:
        The value of the function.
      • getDividend

        public String getDividend()
        Returns the field used as dividend by the function.

        The field name corresponds to a column name in the report's data-row.

        Returns:
        The field name.
      • getDivisor

        public String getDivisor()
        Returns the field used as divisor by the function.

        The field name corresponds to a column name in the report's data row.

        Returns:
        The field name.
      • setDividend

        public void setDividend​(String dividend)
        Sets the field name to be used as dividend for the function.

        The field name corresponds to a column name in the report's data-row.

        Parameters:
        dividend - the field name (null not permitted).
      • setDivisor

        public void setDivisor​(String divisor)
        Sets the field name to be used as divisor for the function.

        The field name corresponds to a column name in the report's data-row.

        Parameters:
        divisor - the field name (null not permitted).
      • getRoundingMode

        public int getRoundingMode()
        Returns the defined rounding mode. This influences the precision of the divide-operation.
        Returns:
        the rounding mode.
        See Also:
        BigDecimal.divide(java.math.BigDecimal, int)
      • setRoundingMode

        public void setRoundingMode​(int roundingMode)
        Defines the rounding mode. This influences the precision of the divide-operation.
        Parameters:
        roundingMode - the rounding mode.
        See Also:
        BigDecimal.divide(java.math.BigDecimal, int)
      • getScale

        public int getScale()
        Returns the scale for the divide-operation. The scale influences the precision of the division.
        Returns:
        the scale.
      • setScale

        public void setScale​(int scale)
        Defines the scale for the divide-operation. The scale influences the precision of the division.
        Parameters:
        scale - the scale.
      • setRuntime

        public void setRuntime​(ExpressionRuntime runtime)
        Defines the ExpressionRune used in this expression. The ExpressionRuntime is set before the expression receives events or gets evaluated and is unset afterwards. Do not hold references on the runtime or you will create memory-leaks.
        Specified by:
        setRuntime in interface Expression
        Overrides:
        setRuntime in class AbstractExpression
        Parameters:
        runtime - the runtime information for the expression
      • getCrosstabFilterGroup

        public String getCrosstabFilterGroup()
      • setCrosstabFilterGroup

        public void setCrosstabFilterGroup​(String crosstabFilterGroup)