org.jfree.report.function
Class TotalItemCountFunction

java.lang.Object
  extended byorg.jfree.report.function.AbstractFunction
      extended byorg.jfree.report.function.TotalItemCountFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener, java.io.Serializable

public class TotalItemCountFunction
extends AbstractFunction
implements java.io.Serializable

A report function that counts the total number of items contained in groups in a report. If a null-groupname is given, all groups are counted.

A group can be defined using the property "group". If the group property is not set, all group starts get counted.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String GROUP_PROPERTY
          Literal text for the 'group' property.
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
TotalItemCountFunction()
          Default constructor.
 
Method Summary
protected  int getCount()
          Returns the current group count value.
 java.lang.String getGroup()
          Returns the name of the group to be totalled.
 Expression getInstance()
          Return a completly separated copy of this function.
 java.lang.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.
protected  void setCount(int count)
          Defines the current group count value.
 void setGroup(java.lang.String group)
          Defines the name of the group to be totalled.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getName, getProperties, getProperty, getProperty, groupFinished, initialize, isActive, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted, setDataRow, setDependencyLevel, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_PROPERTY

public static final java.lang.String GROUP_PROPERTY
Literal text for the 'group' property.

See Also:
Constant Field Values
Constructor Detail

TotalItemCountFunction

public TotalItemCountFunction()
Default constructor.

Method Detail

reportInitialized

public void reportInitialized(ReportEvent event)
Receives notification that a new report is about to start. Resets the count.

Specified by:
reportInitialized in interface ReportListener
Overrides:
reportInitialized in class AbstractFunction
Parameters:
event - the current report event received.

getCount

protected int getCount()
Returns the current group count value.

Returns:
the curernt group count.

groupStarted

public void groupStarted(ReportEvent event)
Receives notification that a new group is about to start. Increases the count if all groups are counted or the name defines the current group.

Specified by:
groupStarted in interface ReportListener
Overrides:
groupStarted in class AbstractFunction
Parameters:
event - the current report event received.

setCount

protected void setCount(int count)
Defines the current group count value.

Parameters:
count - the curernt group count.

getGroup

public java.lang.String getGroup()
Returns the name of the group to be totalled.

Returns:
the group name.

setGroup

public void setGroup(java.lang.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.

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 java.lang.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.

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 interface Expression
Overrides:
getInstance in class AbstractFunction
Returns:
a copy of this function.