final SchemaReader schemaReader =
evaluator.getSchemaReader();
descendantsLeavesByDepth(
member, result, schemaReader, depth);
hierarchizeMemberList(result, false);
return new UnaryTupleList(result);
}
};
} else if (depthSpecified) {
final IntegerCalc depthCalc =
compiler.compileInteger(call.getArg(1));
final Flag flag1 = flag;
return new AbstractListCalc(
call, new Calc[] {memberCalc, depthCalc})
{
public TupleList evaluateList(Evaluator evaluator) {
final Member member = memberCalc.evaluateMember(evaluator);
List<Member> result = new ArrayList<Member>();
final int depth = depthCalc.evaluateInteger(evaluator);
final SchemaReader schemaReader =
evaluator.getSchemaReader();
descendantsByDepth(
member, result, schemaReader,
depth, flag1.before, flag1.self, flag1.after,
evaluator);
hierarchizeMemberList(result, false);
return new UnaryTupleList(result);
}
};
} else {
final LevelCalc levelCalc =
call.getArgCount() > 1
? compiler.compileLevel(call.getArg(1))
: null;
final Flag flag2 = flag;
return new AbstractListCalc(
call, new Calc[] {memberCalc, levelCalc})
{
public TupleList evaluateList(Evaluator evaluator) {
final Evaluator context =
evaluator.isNonEmpty() ? evaluator : null;
final Member member = memberCalc.evaluateMember(evaluator);
List<Member> result = new ArrayList<Member>();
final SchemaReader schemaReader =
evaluator.getSchemaReader();
final Level level =
levelCalc != null
? levelCalc.evaluateLevel(evaluator)
: member.getLevel();
descendantsByLevel(
schemaReader, member, level, result,
flag2.before, flag2.self,
flag2.after, flag2.leaves, context);
hierarchizeMemberList(result, false);
return new UnaryTupleList(result);
}
};
}
}