Definition
An expression is a lightweight function that does not maintain a state. Expressions are used
Excerpt |
---|
Uses script code to calculate values within a single row of |
a report. Expressions can use dataRow to access other fields, expressions or functions within the current row in the Examples
Code Block |
---|
|
<expression class="org.jfree.report.modules.misc.beanshell.BSHExpression" name="totalPrice">
<properties>
<property name="expression">
Object getValue() {
if (dataRow == null) {
return null;
}
Number OrderCount = (Number) dataRow.get("QUANTITYORDERED");
Number SalePrice = (Number) dataRow.get ("PRICEEACH");
if (OrderCount == null || SalePrice == null) {
return null;
}
float totalPrice = OrderCount.floatValue() * SalePrice.floatValue();
return new Float (totalPrice);
}
</property>
</properties>
</expression>
<expression class="org.jfree.report.modules.misc.beanshell.BSHExpression" name="isVarianceNegative">
<properties>
<property name="expression">
Object getValue() {
Object value = dataRow.get("VARIANCE");
if (value instanceof Number == false) {
return Boolean.FALSE;
}
Number number = (Number) value;
if (number.doubleValue() < 0) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
</property>
</properties>
</expression>
|