BSHExpression

Definition

Uses script code to calculate values within a single row of a 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>