org.jfree.report.function
Class ItemPercentageFunction

java.lang.Object
  |
  +--org.jfree.report.function.AbstractExpression
        |
        +--org.jfree.report.function.AbstractFunction
              |
              +--org.jfree.report.function.ItemPercentageFunction

public class ItemPercentageFunction
extends AbstractFunction
implements java.io.Serializable

Calculates the percentage value of a numeric field. The total sum is taken and divided by the number of items counted.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
ItemPercentageFunction()
          Creates a new ItemPercentageFunction.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of the function.
 java.lang.String getField()
          Returns the field used by the function.
 java.lang.String getGroup()
          Returns the group name.
 Expression getInstance()
          Return a completly separated copy of this function.
 java.lang.Object getValue()
          Return the current function value.
 void groupStarted(ReportEvent event)
          Receives notification that a group has started.
 void itemsAdvanced(ReportEvent event)
          Receives notification that a row of data is being processed.
 void reportInitialized(ReportEvent event)
          Receives notification that the report has started.
 void setField(java.lang.String field)
          Sets the field name for the function.
 void setGroup(java.lang.String name)
          Sets the group name.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
 
Methods inherited from class org.jfree.report.function.AbstractExpression
getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, setActive, setDependencyLevel, setName, setRuntime
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ItemPercentageFunction

public ItemPercentageFunction()
Creates a new ItemPercentageFunction.
Method Detail

groupStarted

public void groupStarted(ReportEvent event)
Receives notification that a group has started.
Overrides:
groupStarted in class AbstractFunction
Parameters:
event - the event.

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Receives notification that a row of data is being processed.
Overrides:
itemsAdvanced in class AbstractFunction
Parameters:
event - the event.

reportInitialized

public void reportInitialized(ReportEvent event)
Receives notification that the report has started.
Overrides:
reportInitialized in class AbstractFunction
Parameters:
event - the event.

getValue

public java.lang.Object getValue()
Return the current function value.

Don not count on the correctness of this function until the preparerun has finished.

Returns:
The value of the function.

getGroup

public java.lang.String getGroup()
Returns the group name.
Returns:
The group name.

setGroup

public void setGroup(java.lang.String name)
Sets the group name.

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

Parameters:
name - the group name (null permitted).

getField

public java.lang.String getField()
Returns the field used by the function.

The field name corresponds to a column name in the report's TableModel.

Returns:
The field name.

setField

public void setField(java.lang.String field)
Sets the field name for the function.

The field name corresponds to a column name in the report's TableModel.

Parameters:
field - the field name (null not permitted).

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of the function.

Be aware, this does not create a deep copy. If you have complex strucures contained in objects, you have to overwrite this function.

Overrides:
clone in class AbstractFunction
Returns:
A clone of the function.
Throws:
java.lang.CloneNotSupportedException - this should never happen.

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