Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Definition

An expression is a lightweight function that does not maintain a state. Expressions are used to calculate values within a single row of a report. Expressions can use a dataRow to access other fields, expressions or functions within the current row in the report.

Examples

<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(&quot;QUANTITYORDERED&quot;); 
       Number SalePrice = (Number) dataRow.get (&quot;PRICEEACH&quot;); 
       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(&quot;VARIANCE&quot;);  
      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>
  • No labels