Java Reference
In-Depth Information
element. Variable values can be accessed in other report expressions by using the
$V{variable_name}
notation, where
variable_name
is the name we gave to the
variable by using the
name
attribute in the
<variable>
element.
Output for the preceding example is identical to the output of the example given in
the previous section on
Report Expressions
.
The JRXML
<variable>
element contains a number of attributes. These attributes
are summarized in the following table:
Attribute
Description
Valid Values
Default Value
name
Sets the variable
name.
Any valid XML attribute
value.
N/A
class
Sets the variable
class.
Any Java class available in the
CLASSPATH.
java.lang.
String
calculation
Determines what
calculation to
perform on the
variable when
filling the report.
Average
: The variable value
is the average of every non-
null value of the variable
expression. Valid for numeric
variables only.
Count
: The variable value is
the count of non-null instances
of the variable expression.
First
: The variable value is
the value of the first instance
of the variable expression.
Subsequent values are ignored.
Highest
: The variable value
is the highest value for the
variable expression.
Lowest
: The variable value is
the lowest value in the report
for the variable expression.
Nothing
: No calculations are
performed on the variable.
StandardDeviation
: The
variable value is the standard
deviation of all non-null
values matching the report
expression. Valid for numeric
variables only.
Sum
: The variable value is the
sum of all non-null values
matching the report expression.
Nothing