/*
// $Id: //open/mondrian-release/3.2/src/main/mondrian/olap/fun/StrToMemberFunDef.java#2 $
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2010-2010 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap.fun;
import mondrian.calc.*;
import mondrian.calc.impl.AbstractMemberCalc;
import mondrian.mdx.ResolvedFunCall;
import mondrian.olap.*;
import mondrian.resource.MondrianResource;
/**
* Definition of the <code>StrToMember</code> MDX function.
*
* <p>Syntax:
* <blockquote><code>StrToMember(<String Expression>)
* </code></blockquote>
*
* @version $Id: //open/mondrian-release/3.2/src/main/mondrian/olap/fun/StrToMemberFunDef.java#2 $
*/
class StrToMemberFunDef extends FunDefBase {
public static final FunDef INSTANCE = new StrToMemberFunDef();
private StrToMemberFunDef() {
super(
"StrToMember",
"Returns a member from a unique name String in MDX format.",
"fmS");
}
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final StringCalc memberNameCalc =
compiler.compileString(call.getArg(0));
return new AbstractMemberCalc(call, new Calc[] {memberNameCalc}) {
public Member evaluateMember(Evaluator evaluator) {
String memberName =
memberNameCalc.evaluateString(evaluator);
if (memberName == null) {
throw newEvalException(
MondrianResource.instance().NullValue.ex());
}
return parseMember(evaluator, memberName, null);
}
};
}
}
// End StrToMemberFunDef.java