KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/calc/impl/DimensionCurrentMemberCalc.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.type.MemberType;
14 import mondrian.calc.impl.AbstractMemberCalc;
15 import mondrian.calc.DummyExp;
16 import mondrian.calc.Calc;
17
18 /**
19  * Expression which returns the current member of a given dimension.
20  *
21  * @author jhyde
22  * @version $Id: //open/mondrian/src/main/mondrian/calc/impl/DimensionCurrentMemberCalc.java#2 $
23  * @since Sep 26, 2005
24  */

25 public class DimensionCurrentMemberCalc extends AbstractMemberCalc {
26     private final Dimension dimension;
27
28     public DimensionCurrentMemberCalc(Dimension dimension) {
29         super(
30                 new DummyExp(
31                         MemberType.forHierarchy(dimension.getHierarchy())),
32                 new Calc[0]);
33         this.dimension = dimension;
34     }
35
36     public Member evaluateMember(Evaluator evaluator) {
37         return evaluator.getContext(dimension);
38     }
39
40     public boolean dependsOn(Dimension dimension) {
41         return dimension == this.dimension;
42     }
43 }
44
45 // End DimensionCurrentMemberCalc.java
46
Popular Tags