net.sf.jasperreports.engine
Interface JRVariable

All Superinterfaces:
java.lang.Cloneable, JRCloneable
All Known Implementing Classes:
JRBaseVariable, JRDesignVariable, JRFillVariable

public interface JRVariable
extends JRCloneable

An interface for implementing classes that deal with report variables. This interface defines constants for names of built-in variables and for reset, increment and calculation types.

When declaring a report group, the engine will automatically create a count variable that will calculate the number of records that make up the current group (number of records processed between group ruptures). The name for this variable comes from the name of the group it corresponds to, suffixed with the "_COUNT" sequence. It can be used like any other report variable, in any report expression (even in the current group expression like you can see done in the "BreakGroup" of the jasper sample).

Version:
$Id: JRVariable.java 1950 2007-11-12 15:21:54Z teodord $
Author:
Teodor Danciu (teodord@users.sourceforge.net)

Field Summary
static byte CALCULATION_AVERAGE
          The value is obtained by calculating the average for the series of values obtained by evaluating the variable's expression for each record in the data source.
static byte CALCULATION_COUNT
          The value is calculated by counting the non-null values of the variable expression with every iteration in the data source.
static byte CALCULATION_DISTINCT_COUNT
          The value is calculated by counting the distinct non-null values of the variable expression with every iteration in the data source.
static byte CALCULATION_FIRST
          The variable keeps the first value and does not increment it on subsequent iterations.
static byte CALCULATION_HIGHEST
          The value of the variable represents the highest in the series of values obtained by evaluating the variable's expression for each data source record.
static byte CALCULATION_LOWEST
          The value of the variable represents the lowest in the series of values obtained by evaluating the variable's expression for each data source record.
static byte CALCULATION_NOTHING
          The value is calculated by simply evaluating the variable expression.
static byte CALCULATION_STANDARD_DEVIATION
          The value is obtained by calculating the standard deviation for the series of values returned by evaluating the variable's expression.
static byte CALCULATION_SUM
          The value is calculated by summing up the values returned by the variable's expression.
static byte CALCULATION_SYSTEM
          The value is not calculated by JasperReports.
static byte CALCULATION_VARIANCE
          The value is obtained by calculating the variance for the series of values returned by evaluating the variable's expression.
static java.lang.String COLUMN_COUNT
          This variable contains the number of records that were processed when generating the current column.
static java.lang.String COLUMN_NUMBER
          Built-in variable containing the current column number.
static java.lang.String PAGE_COUNT
          Built-in variable containing the number of records that were processed when generating the current page.
static java.lang.String PAGE_NUMBER
          Built-in variable containing the current page number.
static java.lang.String REPORT_COUNT
          Built-in variable that contains the total number of records read from the datasource.
static byte RESET_TYPE_COLUMN
          The variable is reinitialized at the beginning of each new column.
static byte RESET_TYPE_GROUP
          The variable is reinitialized every time the group specified by the getResetGroup() method breaks.
static byte RESET_TYPE_NONE
          The variable will never be initialized using its initial value expression and will only contain values obtained by evaluating the variable's expression.
static byte RESET_TYPE_PAGE
          The variable is reinitialized at the beginning of each new page.
static byte RESET_TYPE_REPORT
          The variable is initialized only once, at the beginning of the report filling process, with the value returned by the variable's initial value expression.
 
Method Summary
 byte getCalculation()
          Returns the variable calculation type.
 JRExpression getExpression()
          Returns the main expression for this variable.
 java.lang.Class getIncrementerFactoryClass()
          Returns the class of the incrementer factory used for choosing the right incrementer for the variable value.
 java.lang.String getIncrementerFactoryClassName()
          Returns the string name of the variable value class.
 JRGroup getIncrementGroup()
          Returns the group whose break triggers the variable increment.
 byte getIncrementType()
          Returns the variable increment type.
 JRExpression getInitialValueExpression()
          Returns the initial value expression for this variable.
 java.lang.String getName()
          Returns the name of the variable.
 JRGroup getResetGroup()
          Returns the group whose break triggers the variable reset.
 byte getResetType()
          Returns the variable reset type.
 java.lang.Class getValueClass()
          Returns the class of the variable value.
 java.lang.String getValueClassName()
          Returns the string name of the variable value class.
 boolean isSystemDefined()
          Returns true if the variable calculation type is system defined.
 
Methods inherited from interface net.sf.jasperreports.engine.JRCloneable
clone
 

Field Detail

REPORT_COUNT

static final java.lang.String REPORT_COUNT
Built-in variable that contains the total number of records read from the datasource. After finishing iterating throught the datasource, it will contain the total number of records that were processed.

See Also:
Constant Field Values

PAGE_COUNT

static final java.lang.String PAGE_COUNT
Built-in variable containing the number of records that were processed when generating the current page.

See Also:
Constant Field Values

COLUMN_COUNT

static final java.lang.String COLUMN_COUNT
This variable contains the number of records that were processed when generating the current column.

See Also:
Constant Field Values

PAGE_NUMBER

static final java.lang.String PAGE_NUMBER
Built-in variable containing the current page number. At the end of the report filling process, it will contain the total number of pages for the resulting document.

See Also:
Constant Field Values

COLUMN_NUMBER

static final java.lang.String COLUMN_NUMBER
Built-in variable containing the current column number.

See Also:
Constant Field Values

RESET_TYPE_REPORT

static final byte RESET_TYPE_REPORT
The variable is initialized only once, at the beginning of the report filling process, with the value returned by the variable's initial value expression.

See Also:
Constant Field Values

RESET_TYPE_PAGE

static final byte RESET_TYPE_PAGE
The variable is reinitialized at the beginning of each new page.

See Also:
Constant Field Values

RESET_TYPE_COLUMN

static final byte RESET_TYPE_COLUMN
The variable is reinitialized at the beginning of each new column.

See Also:
Constant Field Values

RESET_TYPE_GROUP

static final byte RESET_TYPE_GROUP
The variable is reinitialized every time the group specified by the getResetGroup() method breaks.

See Also:
Constant Field Values

RESET_TYPE_NONE

static final byte RESET_TYPE_NONE
The variable will never be initialized using its initial value expression and will only contain values obtained by evaluating the variable's expression.

See Also:
Constant Field Values

CALCULATION_NOTHING

static final byte CALCULATION_NOTHING
The value is calculated by simply evaluating the variable expression.

See Also:
Constant Field Values

CALCULATION_COUNT

static final byte CALCULATION_COUNT
The value is calculated by counting the non-null values of the variable expression with every iteration in the data source. The count variable must be numeric, but the variable expression needs not, since its value is not important. On the other hand, the initial value expression must be numeric since it will be the count variable initial value.

See Also:
Constant Field Values

CALCULATION_SUM

static final byte CALCULATION_SUM
The value is calculated by summing up the values returned by the variable's expression. Both the main expression and initial expression must have numeric type.

See Also:
Constant Field Values

CALCULATION_AVERAGE

static final byte CALCULATION_AVERAGE
The value is obtained by calculating the average for the series of values obtained by evaluating the variable's expression for each record in the data source. Both the main expression and initial expression must have numeric type.

In order to calculate the average, the engine creates behind the scenes a helper report variable that calculates the sum of the values and uses it to calculate the average for those values. This helper sum variable gets its name from the corresponding average variable suffixed with "_SUM" sequence. This helper variable can be used in other report expressions just like any normal variable.

See Also:
Constant Field Values

CALCULATION_LOWEST

static final byte CALCULATION_LOWEST
The value of the variable represents the lowest in the series of values obtained by evaluating the variable's expression for each data source record.

See Also:
Constant Field Values

CALCULATION_HIGHEST

static final byte CALCULATION_HIGHEST
The value of the variable represents the highest in the series of values obtained by evaluating the variable's expression for each data source record.

See Also:
Constant Field Values

CALCULATION_STANDARD_DEVIATION

static final byte CALCULATION_STANDARD_DEVIATION
The value is obtained by calculating the standard deviation for the series of values returned by evaluating the variable's expression.

Just like for the variables that calculate the average, the engine creates and uses helper report variables for first obtaining the sum and the count that correspond to your current series of values. The name for those helper variables that are created behind the scenes is obtained by suffixing the user variable with the "_SUM" or "_COUNT" suffix and they can be used in other report expressions like any other report variable.

For variables that calculate the standard deviation, there is always a helper variable present, that first calculates the variance for the series of values and it has the "_VARIANCE" suffix added to its name.

See Also:
Constant Field Values

CALCULATION_VARIANCE

static final byte CALCULATION_VARIANCE
The value is obtained by calculating the variance for the series of values returned by evaluating the variable's expression.

See Also:
Constant Field Values

CALCULATION_SYSTEM

static final byte CALCULATION_SYSTEM
The value is not calculated by JasperReports. The user must calculate the value of the variable, almost certainly using the scriptlets functionality. For this type of calculation, the only thing the engine does is to conserve the value users have calculated, from one iteration in the data source to the next.

See Also:
Constant Field Values

CALCULATION_FIRST

static final byte CALCULATION_FIRST
The variable keeps the first value and does not increment it on subsequent iterations.

See Also:
Constant Field Values

CALCULATION_DISTINCT_COUNT

static final byte CALCULATION_DISTINCT_COUNT
The value is calculated by counting the distinct non-null values of the variable expression with every iteration in the data source. The count variable must be numeric, but the variable expression needs not, since its value is not important. On the other hand, the initial value expression must be numeric since it will be the count variable initial value.

See Also:
Constant Field Values
Method Detail

getName

java.lang.String getName()
Returns the name of the variable. Since all variables are stored in a map, the variable names are the keys in the map.

Returns:
a string containing the variable name

getValueClass

java.lang.Class getValueClass()
Returns the class of the variable value. Any class is allowed as long as it is in the classpath at compile and run time.

Returns:
a Class instance representing the variable value class

getValueClassName

java.lang.String getValueClassName()
Returns the string name of the variable value class.


getIncrementerFactoryClass

java.lang.Class getIncrementerFactoryClass()
Returns the class of the incrementer factory used for choosing the right incrementer for the variable value.

Returns:
the Class instance of the incrementer factory
See Also:
JRIncrementer, JRIncrementerFactory

getIncrementerFactoryClassName

java.lang.String getIncrementerFactoryClassName()
Returns the string name of the variable value class.


getResetType

byte getResetType()
Returns the variable reset type. This value must be one of the reset type constants declared in this class.


getIncrementType

byte getIncrementType()
Returns the variable increment type. This value must be one of the reset type constants declared in this class, since the increment type uses the same constants as the reset type.


getCalculation

byte getCalculation()
Returns the variable calculation type. This value must be one of the calculation constants declared in this class.


isSystemDefined

boolean isSystemDefined()
Returns true if the variable calculation type is system defined.

See Also:
CALCULATION_SYSTEM

getExpression

JRExpression getExpression()
Returns the main expression for this variable. The expression must be numeric for certain calculation types.

Returns:
a JRExpression instance containing the expression.

getInitialValueExpression

JRExpression getInitialValueExpression()
Returns the initial value expression for this variable. The expression must be numeric for certain calculation types.

Returns:
a JRExpression instance containing the initial expression.

getResetGroup

JRGroup getResetGroup()
Returns the group whose break triggers the variable reset. Only used when getResetType() returns RESET_TYPE_GROUP.


getIncrementGroup

JRGroup getIncrementGroup()
Returns the group whose break triggers the variable increment. Only used when getIncrementType() returns RESET_TYPE_GROUP.



© 2001-2006 JasperSoft Corporation www.jaspersoft.com