001    /*
002    // $Id: //open/mondrian/src/main/mondrian/calc/impl/DimensionCurrentMemberCalc.java#2 $
003    // This software is subject to the terms of the Common Public License
004    // Agreement, available at the following URL:
005    // http://www.opensource.org/licenses/cpl.html.
006    // Copyright (C) 2006-2006 Julian Hyde
007    // All Rights Reserved.
008    // You must accept the terms of that agreement to use this software.
009    */
010    package mondrian.calc.impl;
011    
012    import mondrian.olap.*;
013    import mondrian.olap.type.MemberType;
014    import mondrian.calc.impl.AbstractMemberCalc;
015    import mondrian.calc.DummyExp;
016    import mondrian.calc.Calc;
017    
018    /**
019     * Expression which returns the current member of a given dimension.
020     *
021     * @author jhyde
022     * @version $Id: //open/mondrian/src/main/mondrian/calc/impl/DimensionCurrentMemberCalc.java#2 $
023     * @since Sep 26, 2005
024     */
025    public class DimensionCurrentMemberCalc extends AbstractMemberCalc {
026        private final Dimension dimension;
027    
028        public DimensionCurrentMemberCalc(Dimension dimension) {
029            super(
030                    new DummyExp(
031                            MemberType.forHierarchy(dimension.getHierarchy())),
032                    new Calc[0]);
033            this.dimension = dimension;
034        }
035    
036        public Member evaluateMember(Evaluator evaluator) {
037            return evaluator.getContext(dimension);
038        }
039    
040        public boolean dependsOn(Dimension dimension) {
041            return dimension == this.dimension;
042        }
043    }
044    
045    // End DimensionCurrentMemberCalc.java