KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractIterCalc.java#3 $
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-2007 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.Evaluator;
13 import mondrian.olap.Exp;
14 import mondrian.olap.type.SetType;
15 import mondrian.calc.IterCalc;
16 import mondrian.calc.Calc;
17 import mondrian.calc.ExpCompiler;
18
19 import java.util.List JavaDoc;
20
21 /**
22  * Abstract implementation of the {@link mondrian.calc.IterCalc} interface.
23  *
24  * <p>The derived class must
25  * implement the {@link #evaluateIterable(mondrian.olap.Evaluator)} method,
26  * and the {@link #evaluate(mondrian.olap.Evaluator)} method will call it.
27  *
28  * @author <a>Richard M. Emberson</a>
29  * @version $Id: //open/mondrian/src/main/mondrian/calc/impl/AbstractIterCalc.java#3 $
30  * @since Jan 14, 2007
31  */

32
33 public abstract class AbstractIterCalc
34         extends AbstractCalc
35         implements IterCalc {
36     private final Calc[] calcs;
37
38     /**
39      * Creates an abstract implementation of a compiled expression which returns
40      * an Iterable.
41      *
42      * @param exp Expression which was compiled
43      * @param calcs List of child compiled expressions (for dependency
44      * analysis)
45      */

46     protected AbstractIterCalc(Exp exp, Calc[] calcs) {
47         super(exp);
48         this.calcs = calcs;
49         assert getType() instanceof SetType : "expecting a set: " + getType();
50     }
51
52     public Object JavaDoc evaluate(Evaluator evaluator) {
53         final Iterable JavaDoc iter = evaluateIterable(evaluator);
54         return iter;
55     }
56
57     public Calc[] getCalcs() {
58         return calcs;
59     }
60
61     public ExpCompiler.ResultStyle getResultStyle() {
62         return ExpCompiler.ResultStyle.ITERABLE;
63     }
64 }
65
66 // End AbstractIterCalc.java
67
Popular Tags