org.jfree.report.function
Class ItemColumnQuotientExpression

java.lang.Object
  extended byorg.jfree.report.function.AbstractExpression
      extended byorg.jfree.report.function.ItemColumnQuotientExpression
All Implemented Interfaces:
java.lang.Cloneable, Expression, java.io.Serializable

public class ItemColumnQuotientExpression
extends AbstractExpression
implements java.io.Serializable

A report function that calculates the quotient of two fields (columns) from the current row.

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 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.

Author:
Heiko Evermann
See Also:
Serialized Form

Field Summary
static java.lang.String DIVIDEND_PROPERTY
          Literal text for the 'dividend' property.
static java.lang.String DIVISOR_PROPERTY
          Literal text for the 'divisor' property.
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
ItemColumnQuotientExpression()
          Constructs a new function.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of the function.
 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.
 Expression getInstance()
          Return a completely separated copy of this function.
 java.lang.Object getValue()
          Return the current function value.
 void initialize()
          Checks that the function has been correctly initialized.
 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.
 
Methods inherited from class org.jfree.report.function.AbstractExpression
getDataRow, getDependencyLevel, getName, getProperties, getProperty, getProperty, isActive, setDataRow, setDependencyLevel, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIVIDEND_PROPERTY

public static final java.lang.String DIVIDEND_PROPERTY
Literal text for the 'dividend' property.

See Also:
Constant Field Values

DIVISOR_PROPERTY

public static final java.lang.String DIVISOR_PROPERTY
Literal text for the 'divisor' property.

See Also:
Constant Field Values
Constructor Detail

ItemColumnQuotientExpression

public ItemColumnQuotientExpression()
Constructs a new function.

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

Method Detail

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.

Specified by:
clone in interface Expression
Overrides:
clone in class AbstractExpression
Returns:
A clone of the function.
Throws:
java.lang.CloneNotSupportedException - this should never happen.

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";

Specified by:
getValue in interface Expression
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).

initialize

public void initialize()
                throws FunctionInitializeException
Checks that the function has been correctly initialized. If there is a problem, this method throws a FunctionInitializeException.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractExpression
Throws:
FunctionInitializeException - if the function name is not set or the call to isInitialized returns false.

getInstance

public Expression getInstance()
Return a completely separated copy of this function. The copy does no longer share any changeable objects with the original function.

Specified by:
getInstance in interface Expression
Overrides:
getInstance in class AbstractExpression
Returns:
a copy of this function.