org.pentaho.reporting.engine.classic.core.modules.misc.bsf
Class BSFExpression

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.AbstractExpression
      extended by org.pentaho.reporting.engine.classic.core.modules.misc.bsf.BSFExpression
All Implemented Interfaces:
Serializable, Cloneable, Expression

public class BSFExpression
extends AbstractExpression

An expression that uses the Bean scripting framework to perform a scripted calculation.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
BSFExpression()
          Default constructor, create a new BeanShellExpression.
 
Method Summary
 Object clone()
          Clones the expression and reinitializes the script.
 String getExpression()
          Returns the script that gets evaluated every time the getValue() method is called.
 String getLanguage()
          Returns the programming language, in which the interpreter work.
 String getScript()
          Returns the script.
 Object getValue()
          Evaluates the defined expression.
 void setExpression(String expression)
          Sets the script that should be executed.
 void setLanguage(String language)
          Defines the programming language of the script and expression.
 void setScript(String script)
          Defines the script.
 
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
 

Constructor Detail

BSFExpression

public BSFExpression()
Default constructor, create a new BeanShellExpression.

Method Detail

getValue

public Object getValue()
Evaluates the defined expression. If an exception or an evaluation error occures, the evaluation returns null and the error is logged. The current datarow and a copy of the expressions properties are set to script-internal variables. Changes to the properties will not alter the expressions original properties and will be lost when the evaluation is finished.

Expressions do not maintain a state and no assumptions about the order of evaluation can be made.

Returns:
the evaluated value or null.

clone

public Object clone()
             throws CloneNotSupportedException
Clones the expression and reinitializes the script.

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

getExpression

public String getExpression()
Returns the script that gets evaluated every time the getValue() method is called.

Returns:
the script.

setExpression

public void setExpression(String expression)
Sets the script that should be executed. Whats in the script depends on what langage is selected.

Parameters:
expression - the script.

getLanguage

public String getLanguage()
Returns the programming language, in which the interpreter work.

Returns:
the programming language, which must be one of the supported BSF-Languages.

setLanguage

public void setLanguage(String language)
Defines the programming language of the script and expression.

Parameters:
language - the programming language of the script.

getScript

public String getScript()
Returns the script. The script is a predefined piece of code that gets executed once. It can (and should) be used to perform global initializations and to define functions.

Returns:
the script (can be null).

setScript

public void setScript(String script)
Defines the script. The script is a predefined piece of code that gets executed once. It can (and should) be used to perform global initializations and to define functions.

Parameters:
script - an initialization script.