KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > calc > impl > AbstractDoubleCalc


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractDoubleCalc.java#2 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2006-2006 Julian Hyde
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.calc.impl;
11
12 import mondrian.olap.*;
13 import mondrian.olap.fun.FunUtil;
14 import mondrian.olap.type.NumericType;
15 import mondrian.calc.impl.AbstractCalc;
16 import mondrian.calc.DoubleCalc;
17 import mondrian.calc.Calc;
18
19 /**
20  * Abstract implementation of the {@link mondrian.calc.DoubleCalc} interface.
21  *
22  * <p>The derived class must
23  * implement the {@link #evaluateDouble(mondrian.olap.Evaluator)} method,
24  * and the {@link #evaluate(mondrian.olap.Evaluator)} method will call it.
25  *
26  * @author jhyde
27  * @version $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractDoubleCalc.java#2 $
28  * @since Sep 27, 2005
29  */

30 public abstract class AbstractDoubleCalc
31         extends AbstractCalc
32         implements DoubleCalc {
33     private final Calc[] calcs;
34
35     protected AbstractDoubleCalc(Exp exp, Calc[] calcs) {
36         super(exp);
37         this.calcs = calcs;
38         assert getType() instanceof NumericType;
39     }
40
41     public Object JavaDoc evaluate(Evaluator evaluator) {
42         final double d = evaluateDouble(evaluator);
43         if (d == FunUtil.DoubleNull) {
44             return null;
45         }
46         return new Double JavaDoc(d);
47     }
48
49     public Calc[] getCalcs() {
50         return calcs;
51     }
52 }
53
54 // End AbstractDoubleCalc.java
55
Popular Tags