A report function that stores the result of a calculation for a group or the complete report. This function
can be used to convert simple running-functions into total-functions by wrapping them up. The wrapped up function
will be evaluated as usual and the result at the end of the report and/or end of the group will be stored in the
TotalCalculationFunction.
| Method from org.jfree.report.function.TotalCalculationFunction Detail: |
public String getField() {
return field;
}
Returns the field used by the function. The field name corresponds to a column name in the report's data-row. |
public String getGroup() {
return group;
}
Returns the name of the group to be totalled. |
public Expression getInstance() {
final TotalCalculationFunction fn =
(TotalCalculationFunction) super.getInstance();
fn.results = new HashMap();
return fn;
}
|
public Object getValue() {
return result;
}
|
public void groupFinished(ReportEvent event) {
if (FunctionUtilities.isDefinedGroup(getGroup(), event) == false)
{
// wrong group ...
return;
}
if (FunctionUtilities.isDefinedPrepareRunLevel(this, event))
{
result = getDataRow().get(getField());
results.put(globalStateKey, result);
if (groupStateKey != null)
{
results.put(groupStateKey, result);
}
}
}
Receives notification that a group has finished. |
public void groupStarted(ReportEvent event) {
if (FunctionUtilities.isDefinedGroup(getGroup(), event) == false)
{
// wrong group ...
return;
}
groupStateKey = event.getState().getProcessKey();
if (FunctionUtilities.isDefinedPrepareRunLevel(this, event))
{
result = getDataRow().get(getField());
results.put(globalStateKey, result);
results.put(groupStateKey, result);
}
else
{
// Activate the current group, which was filled in the prepare run.
result = results.get(groupStateKey);
}
}
Receives notification that a group has started. |
public void reportFinished(ReportEvent event) {
if (FunctionUtilities.isDefinedPrepareRunLevel(this, event))
{
result = getDataRow().get(getField());
results.put(globalStateKey, result);
if (groupStateKey != null)
{
results.put(groupStateKey, result);
}
}
}
Receives notification that the report has finished. |
public void reportInitialized(ReportEvent event) {
globalStateKey = event.getState().getProcessKey();
if (FunctionUtilities.isDefinedPrepareRunLevel(this, event))
{
results.clear();
result = getDataRow().get(getField());
results.put(globalStateKey, result);
}
else
{
result = results.get(globalStateKey);
}
}
Receives notification that the report has started. |
public void setField(String field) {
this.field = field;
}
Sets the field name for the function. The field name corresponds to a column name in the report's data-row. |
public void setGroup(String group) {
this.group = group;
}
Defines the name of the group to be totalled. If the name is null, all groups are totalled. |