org.jfree.report.function
Class PercentageExpression

java.lang.Object
  |
  +--org.jfree.report.function.AbstractExpression
        |
        +--org.jfree.report.function.PercentageExpression
Direct Known Subclasses:
ItemColumnQuotientExpression

public class PercentageExpression
extends AbstractExpression
implements java.io.Serializable

Computes the percentage for a column in relation to a base column.

The function undestands two parameters. The dividend parameter is required and denotes the name of an ItemBand-field which is used as dividend. The divisor parameter is required and denotes the name of an ItemBand-field which is uses as divisor.

If either the divident or the divisor are not numeric, the expression will return null.

The formula used is as follows:

 Percent := divident / divisor
 

If the flag useDifference is set, the difference between base and subject is used instead.

 Percent := (divisor - divident) / divisor
 

Author:
Heiko Evermann, Thomas Morgner
See Also:
Serialized Form

Constructor Summary
PercentageExpression()
          Constructs a new function.
 
Method Summary
 java.lang.String getDividend()
          Returns the field used as dividend by the function.
 java.lang.String getDivisor()
          Returns the field used as divisor by the function.
 java.lang.Object getValue()
          Return the current function value.
 boolean isUseDifference()
           
 void setDividend(java.lang.String dividend)
          Sets the field name to be used as dividend for the function.
 void setDivisor(java.lang.String divisor)
          Sets the field name to be used as divisor for the function.
 void setUseDifference(boolean useDifference)
           
 
Methods inherited from class org.jfree.report.function.AbstractExpression
clone, getDataRow, getDependencyLevel, getInstance, 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

PercentageExpression

public PercentageExpression()
Constructs a new function.

Initially the function has no name...be sure to assign one before using the function.

Method Detail

isUseDifference

public boolean isUseDifference()

setUseDifference

public void setUseDifference(boolean useDifference)

getValue

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

The value is calculated as the quotient of two columns: the dividend column and the divisor column. If the divisor is zero, the return value is "n/a";

Returns:
The quotient

getDividend

public java.lang.String getDividend()
Returns the field used as dividend by the function.

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

Returns:
The field name.

getDivisor

public java.lang.String getDivisor()
Returns the field used as divisor by the function.

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

Returns:
The field name.

setDividend

public void setDividend(java.lang.String dividend)
Sets the field name to be used as dividend for the function.

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

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

setDivisor

public void setDivisor(java.lang.String divisor)
Sets the field name to be used as divisor for the function.

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

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