org.jfree.report.function
Class AbstractExpression

java.lang.Object
  |
  +--org.jfree.report.function.AbstractExpression
Direct Known Subclasses:
AbstractCompareExpression, AbstractFunction, AverageExpression, BSFExpression, BSHExpression, CapitalizeStringExpression, ColumnAggregationExpression, ConvertToDateExpression, ConvertToNumberExpression, DateCutExpression, DateExpression, DateSpanExpression, IsEmptyDataExpression, IsEmptyExpression, IsExportTypeExpression, IsNegativeExpression, IsNullExpression, IsPositiveExpression, MapIndirectExpression, MapStringExpression, PercentageExpression, ResourceBundleLookupExpression, ResourceMesssageFormatExpression, SubStringExpression, SurveyScaleExpression, TextFormatExpression, TokenizeStringExpression, ToLowerCaseStringExpression, ToUpperCaseStringExpression, URLEncodeExpression

public abstract class AbstractExpression
extends java.lang.Object
implements Expression, java.io.Serializable

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

Constructor Summary
protected AbstractExpression()
          Creates an unnamed expression.
 
Method Summary
 java.lang.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.
 java.lang.String getName()
          Returns the name of the expression.
 org.jfree.util.Configuration getReportConfiguration()
           
 ResourceBundleFactory getResourceBundleFactory()
           
protected  ExpressionRuntime getRuntime()
           
 boolean isActive()
          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.
 void setActive(boolean active)
           
 void setDependencyLevel(int level)
          Sets the dependency level for the expression.
 void setName(java.lang.String name)
          Sets the name of the expression.
 void setRuntime(ExpressionRuntime runtime)
          Defines the DataRow used in this expression.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractExpression

protected AbstractExpression()
Creates an unnamed expression. Make sure the name of the expression is set using setName(java.lang.String) before the expression is added to the report's expression collection.
Method Detail

getName

public java.lang.String getName()
Returns the name of the expression.
Specified by:
getName in interface Expression
Returns:
the name.

setName

public void setName(java.lang.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()
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, if the expression is activated automaticly, false otherwise.

setActive

public final void setActive(boolean active)

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 java.lang.Object clone()
                       throws java.lang.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 java.lang.Object
Returns:
a clone of this expression.
Throws:
java.lang.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. Only the datarow may be shared.
Specified by:
getInstance in interface Expression
Returns:
a copy of this function.

getResourceBundleFactory

public ResourceBundleFactory getResourceBundleFactory()
Specified by:
getResourceBundleFactory in interface Expression

getReportConfiguration

public org.jfree.util.Configuration getReportConfiguration()
Specified by:
getReportConfiguration in interface Expression

setRuntime

public void setRuntime(ExpressionRuntime runtime)
Defines the DataRow used in this expression. The dataRow is set when the report processing starts and can be used to access the values of functions, expressions and the reports datasource.
Specified by:
setRuntime in interface Expression
Parameters:
runtime - the runtime information for the expression

getRuntime

protected ExpressionRuntime getRuntime()