"Constructs a set from a string expression.",
Syntax.Function, Category.Set, parameterTypes);
}
public Calc compileCall(ResolvedFunCall call, ExpCompiler compiler) {
final StringCalc stringCalc = compiler.compileString(call.getArg(0));
SetType type = (SetType) call.getType();
Type elementType = type.getElementType();
if (elementType instanceof MemberType) {
final Hierarchy hierarchy = elementType.getHierarchy();
return new AbstractListCalc(call, new Calc[] {stringCalc}) {
public List evaluateList(Evaluator evaluator) {
String string = stringCalc.evaluateString(evaluator);
if (string == null) {
throw newEvalException(
MondrianResource.instance().NullValue.ex());
}
return parseMemberList(evaluator, string, hierarchy);
}
};
} else {
TupleType tupleType = (TupleType) elementType;
final Hierarchy[] hierarchies =
new Hierarchy[tupleType.elementTypes.length];
for (int i = 0; i < tupleType.elementTypes.length; i++) {
hierarchies[i] = tupleType.elementTypes[i].getHierarchy();
}
return new AbstractListCalc(call, new Calc[] {stringCalc}) {
public List evaluateList(Evaluator evaluator) {
String string = stringCalc.evaluateString(evaluator);
if (string == null) {
throw newEvalException(
MondrianResource.instance().NullValue.ex());
}
return parseTupleList(evaluator, string, hierarchies);