Class ItemCountFunction
- 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.ItemCountFunction
-
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,ReportListener,AggregationFunction,Expression,Function
- Direct Known Subclasses:
PageItemCountFunction
public class ItemCountFunction extends AbstractFunction implements AggregationFunction
A report function that counts items in a report. If the "group" property is set, the item count is reset to zero whenever the group changes.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static BigDecimalONEstatic BigDecimalZERO
-
Constructor Summary
Constructors Constructor Description ItemCountFunction()Constructs an unnamed function.ItemCountFunction(String name)Constructs an item count report function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclear()Objectclone()Clones the expression.StringgetCrosstabFilterGroup()StringgetGroup()Returns the name of the group (possibly null) for this function.ItemCountFunctiongetInstance()Return a completly separated copy of this function.ObjectgetValue()Returns the number of items counted (so far) by the function.voidgroupStarted(ReportEvent event)Receives notification that a new group is about to start.voiditemsAdvanced(ReportEvent event)Received notification of a move to the next row of data.voidreportInitialized(ReportEvent event)Receives notification that a new report is about to start.voidsetCrosstabFilterGroup(String crosstabFilterGroup)voidsetGroup(String group)Setss the name of the group for this function.voidsummaryRowSelection(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
-
ONE
public static final BigDecimal ONE
-
ZERO
public static final BigDecimal ZERO
-
-
Constructor Detail
-
ItemCountFunction
public ItemCountFunction()
Constructs an unnamed function.This constructor is intended for use by the SAX handler class only.
-
ItemCountFunction
public ItemCountFunction(String name)
Constructs an item count report function.- Parameters:
name- The name of the function.- Throws:
NullPointerException- if the name is null
-
-
Method Detail
-
clear
protected void clear()
-
reportInitialized
public void reportInitialized(ReportEvent event)
Receives notification that a new report is about to start. The item count is set to zero.- Specified by:
reportInitializedin interfaceReportListener- Overrides:
reportInitializedin classAbstractFunction- Parameters:
event- the event.
-
getGroup
public String getGroup()
Returns the name of the group (possibly null) for this function. The item count is reset to zero at the start of each instance of this group.- Specified by:
getGroupin interfaceAggregationFunction- Returns:
- the group name.
-
setGroup
public void setGroup(String group)
Setss the name of the group for this function. The item count is reset to zero at the start of each instance of this group. If the name is null, all items in the report are counted.- Specified by:
setGroupin interfaceAggregationFunction- Parameters:
group- The group name.
-
groupStarted
public void groupStarted(ReportEvent event)
Receives notification that a new group is about to start. Checks to see if the group that is starting is the same as the group defined for this function...if so, the item count is reset to zero.- Specified by:
groupStartedin interfaceReportListener- Overrides:
groupStartedin classAbstractFunction- Parameters:
event- Information about the event.
-
itemsAdvanced
public void itemsAdvanced(ReportEvent event)
Received notification of a move to the next row of data. Increments the item count.- Specified by:
itemsAdvancedin interfaceReportListener- Overrides:
itemsAdvancedin classAbstractFunction- Parameters:
event- Information about the event.
-
summaryRowSelection
public void summaryRowSelection(ReportEvent event)
Description copied from class:AbstractFunctionA crosstab specific event notifying crosstab-aware functions to select the result for the summary row cell that will be printed next.- Specified by:
summaryRowSelectionin interfaceReportListener- Overrides:
summaryRowSelectionin classAbstractFunction- Parameters:
event- The report event.
-
getValue
public Object getValue()
Returns the number of items counted (so far) by the function. This is either the number of items in the report, or the group (if a group has been defined for the function).- Specified by:
getValuein interfaceExpression- Returns:
- The item count.
-
getCrosstabFilterGroup
public String getCrosstabFilterGroup()
- Specified by:
getCrosstabFilterGroupin interfaceAggregationFunction
-
setCrosstabFilterGroup
public void setCrosstabFilterGroup(String crosstabFilterGroup)
- Specified by:
setCrosstabFilterGroupin interfaceAggregationFunction
-
getInstance
public ItemCountFunction getInstance()
Description copied from class:AbstractExpressionReturn a completly separated copy of this function. The copy does no longer share any changeable objects with the original function.- Specified by:
getInstancein interfaceExpression- Overrides:
getInstancein classAbstractExpression- Returns:
- a copy of this function.
-
clone
public Object clone()
Description copied from class:AbstractExpressionClones 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:
clonein interfaceExpression- Overrides:
clonein classAbstractExpression- Returns:
- a clone of this expression.
-
-