001/* 002// This software is subject to the terms of the Eclipse Public License v1.0 003// Agreement, available at the following URL: 004// http://www.eclipse.org/legal/epl-v10.html. 005// You must accept the terms of that agreement to use this software. 006// 007// Copyright (C) 2009-2009 Pentaho and others 008// All Rights Reserved. 009*/ 010package mondrian.olap.fun; 011 012import mondrian.calc.Calc; 013import mondrian.calc.ExpCompiler; 014import mondrian.calc.impl.ConstantCalc; 015import mondrian.mdx.DimensionExpr; 016import mondrian.mdx.ResolvedFunCall; 017import mondrian.olap.Dimension; 018import mondrian.olap.type.DimensionType; 019 020/** 021 * Definition of the <code><Dimension>.Dimension</code> 022 * MDX builtin function. 023 * 024 * @author jhyde 025 * @since Jul 20, 2009 026 */ 027class DimensionDimensionFunDef extends FunDefBase { 028 public static final FunDefBase INSTANCE = new DimensionDimensionFunDef(); 029 030 private DimensionDimensionFunDef() { 031 super( 032 "Dimension", 033 "Returns the dimension that contains a specified hierarchy.", 034 "pdd"); 035 } 036 037 public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) 038 { 039 Dimension dimension = 040 ((DimensionExpr) call.getArg(0)).getDimension(); 041 return new ConstantCalc( 042 DimensionType.forDimension(dimension), 043 dimension); 044 } 045} 046 047// End DimensionDimensionFunDef.java