Class TotalGroupSumFunction
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.function.AbstractExpression
-
- org.pentaho.reporting.engine.classic.core.function.AbstractFunction
-
- org.pentaho.reporting.engine.classic.core.function.TotalGroupSumFunction
-
- All Implemented Interfaces:
Serializable
,Cloneable
,EventListener
,ReportListener
,AggregationFunction
,Expression
,FieldAggregationFunction
,Function
- Direct Known Subclasses:
TotalPageSumFunction
public class TotalGroupSumFunction extends AbstractFunction implements FieldAggregationFunction
A report function that calculates the sum of one field (column) from the 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 sum for the entire report;
- to calculate a sum within a particular group;
field
parameter is required and denotes the name of an ItemBand-field which gets summed up. The parametergroup
denotes the name of a group. When this group is started, the counter gets reset to null. This parameter is optional.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ReportStateKey
currentGroupKey
The current group key is used to store the result for the current group.protected static BigDecimal
ZERO
A useful constant representing zero.
-
Constructor Summary
Constructors Constructor Description TotalGroupSumFunction()
Constructs a new function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
clear()
Object
clone()
Clones the expression.String
getCrosstabFilterGroup()
String
getField()
Returns the field used by the function.String
getGroup()
Returns the name of the group to be totalled.Expression
getInstance()
Return a completly separated copy of this function.Object
getValue()
Return the current function value.void
groupStarted(ReportEvent event)
Receives notification that a group has started.protected boolean
isPrepareRunLevel(ReportEvent event)
void
itemsAdvanced(ReportEvent event)
Receives notification that a row of data is being processed.void
reportInitialized(ReportEvent event)
Receives notification that the report has started.void
setCrosstabFilterGroup(String crosstabFilterGroup)
void
setField(String field)
Sets the field name for the function.void
setGroup(String group)
Defines the name of the group to be totalled.void
summaryRowSelection(ReportEvent event)
A crosstab specific event notifying crosstab-aware functions to select the result for the summary row cell that will be printed next.-
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractFunction
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setDependencyLevel, setName, setPreserve, setRuntime
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setDependencyLevel, setName, setRuntime
-
Methods inherited from interface org.pentaho.reporting.engine.classic.core.event.ReportListener
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
-
-
-
-
Field Detail
-
ZERO
protected static final BigDecimal ZERO
A useful constant representing zero.
-
currentGroupKey
protected transient ReportStateKey currentGroupKey
The current group key is used to store the result for the current group.
-
-
Method Detail
-
reportInitialized
public void reportInitialized(ReportEvent event)
Receives notification that the report has started.- Specified by:
reportInitialized
in interfaceReportListener
- Overrides:
reportInitialized
in classAbstractFunction
- Parameters:
event
- the event.
-
isPrepareRunLevel
protected boolean isPrepareRunLevel(ReportEvent event)
-
groupStarted
public void groupStarted(ReportEvent event)
Receives notification that a group has started.- Specified by:
groupStarted
in interfaceReportListener
- Overrides:
groupStarted
in classAbstractFunction
- Parameters:
event
- the event.
-
clear
protected void clear()
-
itemsAdvanced
public void itemsAdvanced(ReportEvent event)
Receives notification that a row of data is being processed.- Specified by:
itemsAdvanced
in interfaceReportListener
- Overrides:
itemsAdvanced
in classAbstractFunction
- Parameters:
event
- the event.
-
clone
public Object clone() throws CloneNotSupportedException
Description copied from class:AbstractExpression
Clones the expression. The expression should be reinitialized after the cloning.Expressions maintain no state, cloning is done at the beginning of the report processing to disconnect the expression from any other object space.
- Specified by:
clone
in interfaceExpression
- Overrides:
clone
in classAbstractExpression
- Returns:
- a clone of this expression.
- Throws:
CloneNotSupportedException
- this should never happen.
-
summaryRowSelection
public void summaryRowSelection(ReportEvent event)
Description copied from class:AbstractFunction
A crosstab specific event notifying crosstab-aware functions to select the result for the summary row cell that will be printed next.- Specified by:
summaryRowSelection
in interfaceReportListener
- Overrides:
summaryRowSelection
in classAbstractFunction
- Parameters:
event
- The report event.
-
getGroup
public String getGroup()
Returns the name of the group to be totalled.- Specified by:
getGroup
in interfaceAggregationFunction
- 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.- Specified by:
setGroup
in interfaceAggregationFunction
- 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.
- Specified by:
getValue
in interfaceExpression
- Returns:
- The value of the function.
-
getField
public String getField()
Returns the field used by the function. The field name corresponds to a column name in the report's data-row.- Specified by:
getField
in interfaceFieldAggregationFunction
- Returns:
- The field name.
-
setField
public void setField(String field)
Sets the field name for the function. The field name corresponds to a column name in the report's data-row.- Specified by:
setField
in interfaceFieldAggregationFunction
- Parameters:
field
- the field name.
-
getInstance
public Expression getInstance()
Return a completly separated copy of this function. The copy does no longer share any changeable objects with the original function.- Specified by:
getInstance
in interfaceExpression
- Overrides:
getInstance
in classAbstractExpression
- Returns:
- a copy of this function.
-
getCrosstabFilterGroup
public String getCrosstabFilterGroup()
- Specified by:
getCrosstabFilterGroup
in interfaceAggregationFunction
-
setCrosstabFilterGroup
public void setCrosstabFilterGroup(String crosstabFilterGroup)
- Specified by:
setCrosstabFilterGroup
in interfaceAggregationFunction
-
-