01: package com.calipso.reportgenerator.reportcalculator;
02:
03: import com.calipso.reportgenerator.common.InfoException;
04:
05: import java.io.Serializable;
06:
07: /**
08: *
09: * User: jbassino
10: * Date: 03/11/2004
11: * Time: 14:34:32
12: *
13: */
14: public class MaxStrategy extends MetricCalculationStrategy implements
15: Serializable {
16: /* private boolean firstValue;
17:
18: public MaxStrategy(){
19: firstValue = true;
20: }*/
21:
22: public Object operate(Object[] node, int index, Object measure,
23: Object[] aRow) {
24: /*if(firstValue){
25: firstValue = false;
26: return SharedFloat.newFrom(measure);
27: }*/
28: SharedFloat sharedFloat = (SharedFloat) node[index];
29: if (measure != null) {
30: if (Float.isNaN(sharedFloat.floatValue())) {
31: return measure;
32: }
33: if (sharedFloat.compareTo(measure) >= 0) {
34: return sharedFloat;
35: } else {
36: return measure;
37: }
38: } else {
39: return sharedFloat;
40: }
41: }
42:
43: public String getSQLFunction() throws InfoException {
44: return BasicSQLConstants.MAX;
45: }
46:
47: }
|