// tell us the type.
return super.getResultType(validator, args);
}
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final LevelCalc levelCalc =
call.getArgCount() > 0
? compiler.compileLevel(call.getArg(0))
: null;
final MemberCalc memberCalc =
call.getArgCount() > 1
? compiler.compileMember(call.getArg(1))
: null;
final RolapHierarchy timeHierarchy =
levelCalc == null
? ((RolapCube) compiler.getEvaluator().getCube()).getTimeHierarchy(
getName())
: null;
return new AbstractListCalc(call, new Calc[] {levelCalc, memberCalc}) {
public List evaluateList(Evaluator evaluator) {
final Member member;
final Level level;
if (levelCalc == null) {
member = evaluator.getContext(timeHierarchy);
level = member.getLevel().getParentLevel();
} else {
level = levelCalc.evaluateLevel(evaluator);
if (memberCalc == null) {
member = evaluator.getContext(level.getHierarchy());
} else {
member = memberCalc.evaluateMember(evaluator);
}
}
return periodsToDate(evaluator, level, member);
}
public boolean dependsOn(Hierarchy hierarchy) {
if (super.dependsOn(hierarchy)) {
return true;
}
if (memberCalc != null) {
return false;
} else if (levelCalc != null) {
return levelCalc.getType().usesHierarchy(hierarchy, true);
} else {
return hierarchy == timeHierarchy;
}
}
};