org.jfree.report.function
Class GroupCountFunction

java.lang.Object
  extended byorg.jfree.report.function.AbstractFunction
      extended byorg.jfree.report.function.GroupCountFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener, java.io.Serializable
Direct Known Subclasses:
TotalGroupCountFunction

public class GroupCountFunction
extends AbstractFunction
implements java.io.Serializable

A report function that counts groups in a report. If a null-groupname is given, all groups are counted.

The group to be counted can be defined using the property "group". An optional container group can be defined using the property "parent-group". When the group start event of that group is encountered, the counter will be reset to '0'.

If the group property is not set, all group starts get counted.

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
static java.lang.String GROUP_PROPERTY
          Literal text for the 'group' property.
static java.lang.String PARENTGROUP_PROPERTY
          Literal text for the 'group' property.
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
GroupCountFunction()
          Default constructor.
GroupCountFunction(java.lang.String name, java.lang.String group)
          Constructs a report function for counting groups.
 
Method Summary
protected  int getCount()
          Returns the current group count value.
 java.lang.String getGroup()
          Returns the name of the group to be counted.
 java.lang.String getParentGroup()
          Returns the name of the group on which to reset the counter.
 java.lang.Object getValue()
          Returns the number of groups processed so far (including the current group).
 void groupStarted(ReportEvent event)
          Receives notification that a new group is about to start.
 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 counted.
 void setParentGroup(java.lang.String group)
          defines the name of the group on which to reset the counter.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getInstance, getName, getProperties, getProperty, getProperty, groupFinished, initialize, isActive, itemsAdvanced, 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

PARENTGROUP_PROPERTY

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

See Also:
Constant Field Values
Constructor Detail

GroupCountFunction

public GroupCountFunction()
Default constructor.


GroupCountFunction

public GroupCountFunction(java.lang.String name,
                          java.lang.String group)
Constructs a report function for counting groups.

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

getParentGroup

public java.lang.String getParentGroup()
Returns the name of the group on which to reset the counter.

Returns:
the name of the group or null, if all groups are counted

setParentGroup

public void setParentGroup(java.lang.String group)
defines the name of the group on which to reset the counter. If the name is null, all groups are counted.

Parameters:
group - the name of the group to be counted.

getGroup

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

Returns:
the name of the group or null, if all groups are counted

setGroup

public void setGroup(java.lang.String group)
defines the name of the group to be counted. If the name is null, all groups are counted.

Parameters:
group - the name of the group to be counted.

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.

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.

getCount

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

Returns:
the curernt group count.

setCount

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

Parameters:
count - the curernt group count.

getValue

public java.lang.Object getValue()
Returns the number of groups processed so far (including the current group).

Specified by:
getValue in interface Expression
Returns:
the number of groups processed as java.lang.Integer.