org.jfree.report.function
Class ItemCountFunction

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

public class ItemCountFunction
extends AbstractFunction
implements java.io.Serializable

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
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
ItemCountFunction()
          Constructs an unnamed function.
ItemCountFunction(java.lang.String name)
          Constructs an item count report function.
 
Method Summary
protected  int getCount()
          Returns the current count value.
 java.lang.String getGroup()
          Returns the name of the group (possibly null) for 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 count value.
 void setGroup(java.lang.String group)
          Setss the name of the group for this function.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getInstance, 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

ItemCountFunction

public ItemCountFunction()
Constructs an unnamed function.

This constructor is intended for use by the SAX handler class only.


ItemCountFunction

public ItemCountFunction(java.lang.String name)
Constructs an item count report function.

Parameters:
name - The name of the function.
Throws:
java.lang.NullPointerException - if the name is null
Method Detail

getCount

protected int getCount()
Returns the current count value.

Returns:
the current count value.

setCount

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

Parameters:
count - the current count value.

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

Returns:
the group name.

setGroup

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

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