Save This Page
Home » pentaho-reporting-engine-classic-0.8.10 » org » jfree » report » function » [javadoc | source]
org.jfree.report.function
public class: ItemSumFunction [javadoc | source]
java.lang.Object
   org.jfree.report.function.AbstractExpression
      org.jfree.report.function.AbstractFunction
         org.jfree.report.function.ItemSumFunction

All Implemented Interfaces:
    Function, Expression, Serializable

Direct Known Subclasses:
    PageItemSumFunction, ConditionalItemSumFunction

A report function that calculates the sum of one field (column) from the data-row. This function produces a running total, no global total. For a global sum, use the TotalGroupSumFunction function. The function can be used in two ways: This function expects its input values to be either java.lang.Number instances or Strings that can be parsed to java.lang.Number instances using a java.text.DecimalFormat.

The function undestands two parameters, the field parameter is required and denotes the name of an ItemBand-field which gets summed up.

The parameter group denotes the name of a group. When this group is started, the counter gets reseted to null.

Field Summary
protected static final  BigDecimal ZERO    A useful constant representing zero. 
Constructor:
 public ItemSumFunction() 
 public ItemSumFunction(String name) 
    Constructs a named function.

    The field must be defined before using the function.

    Parameters:
    name - The function name.
Method from org.jfree.report.function.ItemSumFunction Summary:
getField,   getGroup,   getInstance,   getSum,   getValue,   groupStarted,   itemsAdvanced,   reportInitialized,   setField,   setGroup,   setSum
Methods from org.jfree.report.function.AbstractFunction:
groupFinished,   groupStarted,   itemsAdvanced,   itemsFinished,   itemsStarted,   reportDone,   reportFinished,   reportInitialized,   reportStarted
Methods from org.jfree.report.function.AbstractExpression:
clone,   getDataRow,   getDependencyLevel,   getInstance,   getName,   getReportConfiguration,   getResourceBundleFactory,   getRuntime,   isActive,   isDeepTraversing,   isPreserve,   setActive,   setDependencyLevel,   setName,   setPreserve,   setRuntime
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jfree.report.function.ItemSumFunction Detail:
 public String getField() 
    Returns the field used by the function. The field name corresponds to a column name in the report's data-row.
 public String getGroup() 
    Returns the group name.
 public Expression getInstance() 
    Return a completly separated copy of this function. The copy does no longer share any changeable objects with the original function.
 protected BigDecimal getSum() 
    Returns the current sum.
 public Object getValue() 
    Returns the function value, in this case the running total of a specific column in the report's data-row.
 public  void groupStarted(ReportEvent event) 
    Receives notification that a new group is about to start. If this is the group defined for the function, then the running total is reset to zero.
 public  void itemsAdvanced(ReportEvent event) 
    Receives notification that a row of data is being processed. Reads the data from the field defined for this function and adds it to the running total.

    This function assumes that it will find an instance of the Number class in the column of the data-row specified by the field name.

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

    Does nothing.

 public  void setField(String 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 name) 
    Sets the group name.

    If a group is defined, the running total is reset to zero at the start of every instance of this group.

 protected  void setSum(BigDecimal sum) 
    Defines the current sum.