public interface JRVariable extends JRCloneable
<variable>
element is
mandatory and allows referencing the variable by its declared name in report
expressions.
java.lang.String
, but you can declare report variables of any class as
long as the class is available in the classpath, both at report-compilation time and report-filling
time.
None
- The variable will never be initialized using its initial value expression and
will only contain values obtained by evaluating the variable's expressionReport
- The variable is initialized only once, at the beginning of the
report-filling process, with the value returned by the variable's initial value
expressionPage
- The variable is reinitialized at the beginning of each new page.Column
- The variable is reinitialized at the beginning of each new columnGroup
- The variable is reinitialized every time the group specified by
the resetGroup
attributes breaksresetGroup
attribute contains the name of a report group and works only
in conjunction with the resetType
attribute, whose value must be
resetType="Group"
.
None
- The variable is incremented with every record during the
iteration through the data sourceReport
- The variable never gets incremented during the report filling process.Page
- The variable is incremented with each new page.Column
- The variable is incremented with each new column.Group
- The variable is incremented every time the group specified
by the incrementGroup
attributes breaksincrementGroup
attribute contains the name of a report group. It works
only in conjunction with the incrementType
attribute, whose value must be
incrementType="Group"
.
calculation
attribute of the <variable>
element.
Nothing
Count
DistinctCount
Count
calculation, the only difference being
that it ignores repeating values and counts only for distinct non-null values.Sum
java.lang.String
or java.util.Date
type of report
variable unless a customized variable incrementer is used.Average
Lowest
and Highest
StandardDeviation
and Variance
System
First
First
, the variable will keep the value obtained after
the first incrementation and will not change it until the reset event occurs.Quantity
:
<variable name="QuantitySum" class="java.lang.Double" calculation="Sum"> <variableExpression>$F{Quantity}</variableExpression> </variable>If you want the sum of this field for each page, here's the complete variable declaration:
<variable name="QuantitySum" class="java.lang.Double" resetType="Page" calculation="Sum"> <variableExpression>$F{Quantity}</variableExpression> <initialValueExpression>new Double(0)</initialValueExpression> </variable>In this example, the page sum variable will be initialized with zero at the beginning of each new page.
JRIncrementer
interface and
associate that implementation with a report variable that shows the JasperReports engine
how to handle that custom calculation.
To associate custom types of calculations with a given report variable, set the
incrementerFactoryClass
attribute to the name of a class that implements the
JRIncrementerFactory
interface. The
factory class will be used by the engine to instantiate incrementer objects at runtime
depending on the calculation attribute set for the variable.
Such customized calculations could be useful for making JasperReports sum up
java.lang.String
values or for teaching it how to calculate the average value of some
custom-made numeric data (third-party optimized implementations of big decimal
numbers, for instance).
_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).Modifier and Type | Field and Description |
---|---|
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 |
MASTER_CURRENT_PAGE
A variable that provides the current master report page number.
|
static java.lang.String |
MASTER_TOTAL_PAGES
A variable that provides the number of master report pages.
|
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.
|
Modifier and Type | Method and Description |
---|---|
CalculationEnum |
getCalculationValue()
Gets 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.
|
IncrementTypeEnum |
getIncrementTypeValue()
Gets 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.
|
ResetTypeEnum |
getResetTypeValue()
Gets 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. |
clone
static final java.lang.String REPORT_COUNT
static final java.lang.String PAGE_COUNT
static final java.lang.String COLUMN_COUNT
static final java.lang.String PAGE_NUMBER
static final java.lang.String COLUMN_NUMBER
static final java.lang.String MASTER_CURRENT_PAGE
It can only be used in text elements with Master
evaluation time,
it evaluates to null
before the moment in which master elements are resolved.
static final java.lang.String MASTER_TOTAL_PAGES
It can only be used in text elements with Master
evaluation time,
it evaluates to null
before the moment in which master elements are resolved.
java.lang.String getName()
java.lang.Class<?> getValueClass()
java.lang.String getValueClassName()
java.lang.Class<?> getIncrementerFactoryClass()
JRIncrementer
,
JRIncrementerFactory
java.lang.String getIncrementerFactoryClassName()
ResetTypeEnum getResetTypeValue()
ResetTypeEnum
IncrementTypeEnum getIncrementTypeValue()
IncrementTypeEnum
CalculationEnum getCalculationValue()
CalculationEnum
boolean isSystemDefined()
true
if the variable calculation type is system defined.CalculationEnum.SYSTEM
JRExpression getExpression()
JRExpression
instance containing the expression.JRExpression getInitialValueExpression()
JRExpression
instance containing the initial expression.JRGroup getResetGroup()
getResetTypeValue()
returns
ResetTypeEnum.GROUP
.JRGroup getIncrementGroup()
getIncrementTypeValue()
returns
IncrementTypeEnum.GROUP
.© 2001-2014 TIBCO Software Inc. www.jaspersoft.com