org.pentaho.reporting.engine.classic.core.function
Class ItemCountFunction

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.AbstractExpression
      extended by org.pentaho.reporting.engine.classic.core.function.AbstractFunction
          extended by 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

Constructor Summary
ItemCountFunction()
          Constructs an unnamed function.
ItemCountFunction(String name)
          Constructs an item count report function.
 
Method Summary
 String getGroup()
          Returns the name of the group (possibly null) for 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 setGroup(String group)
          Setss the name of the group for this function.
 
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
clone, getDataRow, getDependencyLevel, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setDependencyLevel, setName, setPreserve, setRuntime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.event.ReportListener
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
clone, getDataRow, getDependencyLevel, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setDependencyLevel, setName, setRuntime
 

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

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 interface ReportListener
Overrides:
reportInitialized in class AbstractFunction
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 interface AggregationFunction
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 interface AggregationFunction
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 interface ReportListener
Overrides:
groupStarted in class AbstractFunction
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 interface ReportListener
Overrides:
itemsAdvanced in class AbstractFunction
Parameters:
event - Information about the 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 interface Expression
Returns:
The item count.