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

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.AbstractExpression
All Implemented Interfaces:
Serializable, Cloneable, Expression
Direct Known Subclasses:
AbstractCompareExpression, AbstractFunction, AverageExpression, BSFExpression, BSHExpression, CapitalizeStringExpression, ColumnAggregationExpression, ConvertToDateExpression, ConvertToNumberExpression, DateCutExpression, DateExpression, DateSpanExpression, FormulaExpression, GetDataRowValueExpression, IsEmptyDataExpression, IsEmptyExpression, IsExportTypeExpression, IsNegativeExpression, IsNullExpression, IsPositiveExpression, MapIndirectExpression, MapStringExpression, MessageFormatExpression, PercentageExpression, ResourceBundleLookupExpression, ResourceMesssageFormatExpression, SubStringExpression, SurveyScaleExpression, TextFormatExpression, TokenizeStringExpression, ToLowerCaseStringExpression, ToUpperCaseStringExpression, URLEncodeExpression

public abstract class AbstractExpression
extends Object
implements Expression

An abstract base class for implementing new report expressions.

Expressions are stateless functions which have access to the report's DataRow. All expressions are named and the defined names have to be unique within the report's expressions, functions and fields of the datasource. Expressions are configured using properties.

Author:
Thomas Morgner
See Also:
Serialized Form

Method Summary
 Object clone()
          Clones the expression.
 DataRow getDataRow()
          Returns the current DataRow.
 int getDependencyLevel()
          Returns the dependency level for the expression (controls evaluation order for expressions and functions).
 Expression getInstance()
          Return a completly separated copy of this function.
 String getName()
          Returns the name of the expression.
 org.pentaho.reporting.libraries.base.config.Configuration getReportConfiguration()
          Returns the report's current configuration.
 ResourceBundleFactory getResourceBundleFactory()
          Returns the resource-bundle factory of the report.
 ExpressionRuntime getRuntime()
          Returns the ExpressionRune used in this expression.
 boolean isActive()
          Deprecated. The Active-Flag is no longer evaluated. We always assume it to be true.
 boolean isDeepTraversing()
          Checks whether this expression is a deep-traversing expression.
 boolean isPreserve()
          Checks whether this expression's last value is preserved after the expression goes out of scope.
 void setActive(boolean active)
          Deprecated. All expressions are always active. This method has no effect anymore.
 void setDependencyLevel(int level)
          Sets the dependency level for the expression.
 void setName(String name)
          Sets the name of the expression.
 void setPreserve(boolean preserve)
          Defines, whether this expression's last value is preserved after the expression goes out of scope.
 void setRuntime(ExpressionRuntime runtime)
          Defines the ExpressionRune used in this expression.
 
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
getValue
 

Method Detail

getName

public String getName()
Returns the name of the expression.

Specified by:
getName in interface Expression
Returns:
the name.

setName

public void setName(String name)
Sets the name of the expression.

The name should be unique among:

This allows the expression to be referenced by name from any report element.

You should not change the name of an expression once it has been added to the report's expression collection.

Specified by:
setName in interface Expression
Parameters:
name - the name (null not permitted).

isActive

public final boolean isActive()
Deprecated. The Active-Flag is no longer evaluated. We always assume it to be true.

Returns true if this expression contains "auto-active" content and should be called by the system regardless of whether this expression is referenced in the DataRow.

Specified by:
isActive in interface Expression
Returns:
true as all expressions are always evaluated now.

setActive

public final void setActive(boolean active)
Deprecated. All expressions are always active. This method has no effect anymore.

Defines, whether the expression is an active expression. This method has no effect anymore.

Parameters:
active - a flag.

getDependencyLevel

public int getDependencyLevel()
Returns the dependency level for the expression (controls evaluation order for expressions and functions).

Specified by:
getDependencyLevel in interface Expression
Returns:
the level.

setDependencyLevel

public void setDependencyLevel(int level)
Sets the dependency level for the expression.

The dependency level controls the order of evaluation for expressions and functions. Higher level expressions are evaluated before lower level expressions. Any level in the range 0 to Integer.MAX_VALUE is allowed. Negative values are reserved for system functions (printing and layouting).

Specified by:
setDependencyLevel in interface Expression
Parameters:
level - the level (must be greater than or equal to 0).

getDataRow

public DataRow getDataRow()
Returns the current DataRow.

Specified by:
getDataRow in interface Expression
Returns:
the data row.

clone

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

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

Specified by:
clone in interface Expression
Overrides:
clone in class Object
Returns:
a clone of this expression.
Throws:
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.

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

getResourceBundleFactory

public ResourceBundleFactory getResourceBundleFactory()
Description copied from interface: Expression
Returns the resource-bundle factory of the report. This factory encapsulates the Locale and allows to create a resource-bundle in a implementation-independent way.

Specified by:
getResourceBundleFactory in interface Expression
Returns:
the resource-bundle factory.

getReportConfiguration

public org.pentaho.reporting.libraries.base.config.Configuration getReportConfiguration()
Description copied from interface: Expression
Returns the report's current configuration.

Specified by:
getReportConfiguration in interface Expression
Returns:
the configuration of the report.

setRuntime

public void setRuntime(ExpressionRuntime runtime)
Defines the ExpressionRune used in this expression. The ExpressionRuntime is set before the expression receives events or gets evaluated and is unset afterwards. Do not hold references on the runtime or you will create memory-leaks.

Specified by:
setRuntime in interface Expression
Parameters:
runtime - the runtime information for the expression

getRuntime

public ExpressionRuntime getRuntime()
Returns the ExpressionRune used in this expression. The ExpressionRuntime is set before the expression receives events or gets evaluated and is unset afterwards. Do not hold references on the runtime or you will create memory-leaks.

Specified by:
getRuntime in interface Expression
Returns:
the runtime information for the expression

isDeepTraversing

public boolean isDeepTraversing()
Checks whether this expression is a deep-traversing expression. Deep-traversing expressions receive events from all sub-reports. This returns false by default, as ordinary expressions have no need to be deep-traversing.

Specified by:
isDeepTraversing in interface Expression
Returns:
false.

isPreserve

public boolean isPreserve()
Checks whether this expression's last value is preserved after the expression goes out of scope.

Specified by:
isPreserve in interface Expression
Returns:
true, if the expression's last value is preserved, false otherwise.

setPreserve

public void setPreserve(boolean preserve)
Defines, whether this expression's last value is preserved after the expression goes out of scope.

Parameters:
preserve - true, if the expression's last value is preserved, false otherwise.