Class TotalGroupSumQuotientFunction
- 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.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;
dividend
parameter is required and denotes the name of an ItemBand-field which gets summed up as dividend. Thedivisor
parameter is required and denotes the name of an ItemBand-field which gets summed up as divisor. The parametergroup
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 Summary
Constructors Constructor Description TotalGroupSumQuotientFunction()
Constructs a new function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Clones the expression.String
getCrosstabFilterGroup()
String
getDividend()
Returns the field used as dividend by the function.String
getDivisor()
Returns the field used as divisor by the function.String
getGroup()
Returns the name of the group to be totalled.int
getRoundingMode()
Returns the defined rounding mode.int
getScale()
Returns the scale for the divide-operation.Object
getValue()
Return the current function value.void
groupStarted(ReportEvent event)
Receives notification that a group has started.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
setDependencyLevel(int level)
Defines the function's dependency level.void
setDividend(String dividend)
Sets the field name to be used as dividend for the function.void
setDivisor(String divisor)
Sets the field name to be used as divisor for the function.void
setGroup(String group)
Defines the name of the group to be totalled.void
setRoundingMode(int roundingMode)
Defines the rounding mode.void
setRuntime(ExpressionRuntime runtime)
Defines the ExpressionRune used in this expression.void
setScale(int scale)
Defines the scale for the divide-operation.-
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractFunction
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted, summaryRowSelection
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
getDataRow, getDependencyLevel, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setName, setPreserve
-
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, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setName
-
-
-
-
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.
-
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.
-
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.
-
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.
-
setDependencyLevel
public void setDependencyLevel(int level)
Defines the function's dependency level. This method forwards all calls to the interal functions.- Specified by:
setDependencyLevel
in interfaceExpression
- Overrides:
setDependencyLevel
in classAbstractExpression
- Parameters:
level
- the dependency level.- See Also:
Expression.getDependencyLevel()
-
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 interfaceExpression
- Overrides:
setRuntime
in classAbstractExpression
- Parameters:
runtime
- the runtime information for the expression
-
getCrosstabFilterGroup
public String getCrosstabFilterGroup()
-
setCrosstabFilterGroup
public void setCrosstabFilterGroup(String crosstabFilterGroup)
-
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.
-
-