KickJava   Java API By Example, From Geeks To Geeks.

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


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:34:32
12  *
13  */

14 public class MaxStrategy extends MetricCalculationStrategy implements Serializable JavaDoc {
15 /* private boolean firstValue;
16
17   public MaxStrategy(){
18     firstValue = true;
19   }*/

20
21
22   public Object JavaDoc operate(Object JavaDoc[] node, int index, Object JavaDoc measure, Object JavaDoc[] aRow) {
23     /*if(firstValue){
24       firstValue = false;
25       return SharedFloat.newFrom(measure);
26     }*/

27     SharedFloat sharedFloat = (SharedFloat)node[index];
28     if (measure!=null){
29       if(Float.isNaN(sharedFloat.floatValue())){
30         return measure;
31       }
32       if(sharedFloat.compareTo(measure) >= 0){
33         return sharedFloat;
34       }else{
35         return measure;
36       }
37     } else{
38         return sharedFloat;
39     }
40   }
41
42   public String JavaDoc getSQLFunction() throws InfoException {
43     return BasicSQLConstants.MAX;
44   }
45
46 }
47
Popular Tags