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 BigDecimal
ONE
static BigDecimal
ZERO
-
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 void
clear()
Object
clone()
Clones the expression.String
getCrosstabFilterGroup()
String
getGroup()
Returns the name of the group (possibly null) for this function.ItemCountFunction
getInstance()
Return a completly separated copy of this function.Object
getValue()
Returns the number of items counted (so far) by the function.void
groupStarted(ReportEvent event)
Receives notification that a new group is about to start.void
itemsAdvanced(ReportEvent event)
Received notification of a move to the next row of data.void
reportInitialized(ReportEvent event)
Receives notification that a new report is about to start.void
setCrosstabFilterGroup(String crosstabFilterGroup)
void
setGroup(String group)
Setss the name of the group for this function.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
-
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:
reportInitialized
in interfaceReportListener
- Overrides:
reportInitialized
in 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:
getGroup
in 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:
setGroup
in 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:
groupStarted
in interfaceReportListener
- Overrides:
groupStarted
in 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:
itemsAdvanced
in interfaceReportListener
- Overrides:
itemsAdvanced
in classAbstractFunction
- Parameters:
event
- Information about the event.
-
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.
-
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:
getValue
in interfaceExpression
- Returns:
- The item count.
-
getCrosstabFilterGroup
public String getCrosstabFilterGroup()
- Specified by:
getCrosstabFilterGroup
in interfaceAggregationFunction
-
setCrosstabFilterGroup
public void setCrosstabFilterGroup(String crosstabFilterGroup)
- Specified by:
setCrosstabFilterGroup
in interfaceAggregationFunction
-
getInstance
public ItemCountFunction getInstance()
Description copied from class:AbstractExpression
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.
-
clone
public Object clone()
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.
-
-