| |
|
| java.lang.Object org.jfree.report.function.AbstractExpression org.jfree.report.function.AbstractFunction org.jfree.report.function.ItemSumFunction
All known Subclasses: org.jfree.report.function.PageItemSumFunction, org.jfree.report.function.ConditionalItemSumFunction,
ItemSumFunction | public class ItemSumFunction extends AbstractFunction (Code) | | A report function that calculates the sum of one field (column) from the data-row. This function produces a running
total, no global total. For a global sum, use the TotalGroupSumFunction function. The function can be used in two
ways: - to calculate a sum for the entire report;
- to calculate a sum 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 two parameters, the field parameter is required and denotes the name of an
ItemBand-field which gets summed up.
The parameter group denotes the name of a group. When this group is started, the counter gets reseted to
null.
author: Thomas Morgner |
Field Summary | |
final protected static BigDecimal | ZERO A useful constant representing zero. |
ZERO | final protected static BigDecimal ZERO(Code) | | A useful constant representing zero.
|
ItemSumFunction | public ItemSumFunction()(Code) | | Constructs an unnamed function. Make sure to set a Name or function initialisation will fail.
|
ItemSumFunction | public ItemSumFunction(String name)(Code) | | Constructs a named function. The field must be defined before using the function.
Parameters: name - The function name. |
getField | public String getField()(Code) | | Returns the field used by the function. The field name corresponds to a column name in the report's data-row.
The field name. |
getGroup | public String getGroup()(Code) | | Returns the group name.
The group name. |
getInstance | public Expression getInstance()(Code) | | Return a completly separated copy of this function. The copy does no longer share any changeable objects with the
original function.
a copy of this function. |
getSum | protected BigDecimal getSum()(Code) | | Returns the current sum.
the current sum. |
getValue | public Object getValue()(Code) | | Returns the function value, in this case the running total of a specific column in the report's data-row.
The function value. |
groupStarted | public void groupStarted(ReportEvent event)(Code) | | Receives notification that a new group is about to start. If this is the group defined for the function, then the
running total is reset to zero.
Parameters: event - Information about the event. |
itemsAdvanced | public void itemsAdvanced(ReportEvent event)(Code) | | Receives notification that a row of data is being processed. Reads the data from the field defined for this
function and adds it to the running total. This function assumes that it will find an instance of the Number
class in the column of the data-row specified by the field name.
Parameters: event - Information about the event. |
reportInitialized | public void reportInitialized(ReportEvent event)(Code) | | Receives notification that a new report is about to start. Does nothing.
Parameters: event - Information about the event. |
setField | public void setField(String field)(Code) | | Sets the field name for the function. The field name corresponds to a column name in the report's data-row.
Parameters: field - the field name. |
setGroup | public void setGroup(String name)(Code) | | Sets the group name. If a group is defined, the running total is reset to zero at the start of every instance
of this group.
Parameters: name - the group name (null permitted). |
setSum | protected void setSum(BigDecimal sum)(Code) | | Defines the current sum.
Parameters: sum - the current sum. |
|
|
|