org.pentaho.reporting.engine.classic.core.function
Class FormulaFunction

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.AbstractExpression
      extended by org.pentaho.reporting.engine.classic.core.function.AbstractFunction
          extended by org.pentaho.reporting.engine.classic.core.function.FormulaFunction
All Implemented Interfaces:
Serializable, Cloneable, EventListener, ReportListener, Expression, Function

public final class FormulaFunction
extends AbstractFunction

The formula function is a stateful version of the FormulaExpression and is used to evaluate a LibFormula/OpenFormula expression. This function can be used if a stateful evaluation is needed or if the formula value should be initialized to a certain value before the real evaluation starts.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
FormulaFunction()
          Default Constructor.
 
Method Summary
 Object clone()
          Clones the expression, expression should be reinitialized after the cloning.
 String getFormula()
          Returns the formula (incuding the optional namespace) as defined by the OpenFormula standard.
 String getFormulaExpression()
          Returns the formula expression.
 String getFormulaNamespace()
          Returns the formula namespace.
 String getInitial()
          Returns the initial formula (incuding the optional namespace) as defined by the OpenFormula standard.
 String getInitialExpression()
          Returns the initial formula expression.
 String getInitialNamespace()
          Returns the formula namespace if the initial formula.
 Object getValue()
          Return the computed value of the formula.
 void reportInitialized(ReportEvent event)
          Resets the function state.
 void setFormula(String formula)
          Defines the formula (incuding the optional namespace) as defined by the OpenFormula standard.
 void setInitial(String initial)
          Defines the initial formula (incuding the optional namespace) as defined by the OpenFormula standard.
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractFunction
groupFinished, groupStarted, itemsAdvanced, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
getDataRow, getDependencyLevel, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setDependencyLevel, setName, setPreserve, setRuntime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
getDataRow, getDependencyLevel, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setDependencyLevel, setName, setRuntime
 

Constructor Detail

FormulaFunction

public FormulaFunction()
Default Constructor.

Method Detail

getInitial

public String getInitial()
Returns the initial formula (incuding the optional namespace) as defined by the OpenFormula standard.

Returns:
the formula as text.

getInitialExpression

public String getInitialExpression()
Returns the initial formula expression. The initial formula is used at the first call only.

Returns:
the initial formula expression.

getInitialNamespace

public String getInitialNamespace()
Returns the formula namespace if the initial formula. If the formula specified by the user starts with "=", then the namespace "report" is assumed.

Returns:
the namespace of the formula.

setInitial

public void setInitial(String initial)
Defines the initial formula (incuding the optional namespace) as defined by the OpenFormula standard. The initial formula is used at the first call only.

Parameters:
initial - the initial formula as text.

reportInitialized

public void reportInitialized(ReportEvent event)
Resets the function state.

Specified by:
reportInitialized in interface ReportListener
Overrides:
reportInitialized in class AbstractFunction
Parameters:
event - the report event.

getFormula

public String getFormula()
Returns the formula (incuding the optional namespace) as defined by the OpenFormula standard.

Returns:
the formula as text.

getFormulaNamespace

public String getFormulaNamespace()
Returns the formula namespace. If the formula specified by the user starts with "=", then the namespace "report" is assumed.

Returns:
the namespace of the formula.

getFormulaExpression

public String getFormulaExpression()
Returns the formula expression.

Returns:
the formula expression.

setFormula

public void setFormula(String formula)
Defines the formula (incuding the optional namespace) as defined by the OpenFormula standard.

Parameters:
formula - the formula as text.

getValue

public Object getValue()
Return the computed value of the formula. The first call will return the initial-value instead.

Returns:
the value of the function.

clone

public Object clone()
             throws CloneNotSupportedException
Clones the expression, expression should be reinitialized after the cloning.

Expression maintain no state, cloning is done at the beginning of the report processing to disconnect the used expression from any other object space.

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