Class AbstractExpression
- java.lang.Object
-
- 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'sDataRow
. 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractExpression()
Creates an unnamed expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
clone()
Clones the expression.DataRow
getDataRow()
Returns the currentDataRow
.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.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.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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
getValue
-
-
-
-
Constructor Detail
-
AbstractExpression
protected AbstractExpression()
Creates an unnamed expression. Make sure the name of the expression is set usingsetName(java.lang.String)
before the expression is added to the report's expression collection.
-
-
Method Detail
-
getName
public String getName()
Returns the name of the expression.- Specified by:
getName
in interfaceExpression
- Returns:
- the name.
-
setName
public void setName(String name)
Sets the name of the expression.The name should be unique among:
- the functions and expressions for the report;
- the columns in the report's
TableModel
;
- Specified by:
setName
in interfaceExpression
- 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.Returnstrue
if this expression contains "auto-active" content and should be called by the system regardless of whether this expression is referenced in theDataRow
.- Specified by:
isActive
in interfaceExpression
- 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 interfaceExpression
- 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 interfaceExpression
- Parameters:
level
- the level (must be greater than or equal to 0).
-
getDataRow
public DataRow getDataRow()
Returns the currentDataRow
.- Specified by:
getDataRow
in interfaceExpression
- 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 interfaceExpression
- Overrides:
clone
in classObject
- 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 interfaceExpression
- 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 interfaceExpression
- 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 interfaceExpression
- 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 interfaceExpression
- 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 interfaceExpression
- 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 interfaceExpression
- 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 interfaceExpression
- 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.
-
-