KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > SumStrategy


1 package com.calipso.reportgenerator.reportcalculator;
2
3 import com.calipso.reportgenerator.common.InfoException;
4
5 import java.io.Serializable JavaDoc;
6
7 /**
8  *
9  * User: jbassino
10  * Date: 03/11/2004
11  * Time: 14:32:10
12  *
13  */

14 public class SumStrategy extends MetricCalculationStrategy implements Serializable JavaDoc {
15
16   public Object JavaDoc operate(Object JavaDoc[] node, int index, Object JavaDoc measure, Object JavaDoc[] aRow) {
17     SharedFloat sharedFloat = (SharedFloat)node[index];
18     if (measure!=null){
19       if(Float.isNaN(sharedFloat.floatValue())){
20         return measure;//SharedFloat.newFrom((Float)measure);
21
}
22       return sharedFloat.add((SharedFloat)measure);
23     }else{
24       return sharedFloat;
25     }
26   }
27
28   public String JavaDoc getSQLFunction() throws InfoException {
29     return BasicSQLConstants.SUM;
30   }
31 }
32
Popular Tags