use of org.mvel2.util.ParseTools.findClass in project mvel by mikebrock.
the class ForEachNode method handleCond.
private void handleCond(char[] condition, int start, int offset, int fields, ParserContext pCtx) {
int cursor = start;
int end = start + offset;
while (cursor < end && condition[cursor] != ':') cursor++;
if (cursor == end || condition[cursor] != ':')
throw new CompileException("expected : in foreach", condition, cursor);
int x;
if ((x = (item = createStringTrimmed(condition, start, cursor - start)).indexOf(' ')) != -1) {
String tk = new String(condition, start, x).trim();
try {
itemType = ParseTools.findClass(null, tk, pCtx);
item = new String(condition, start + x, (cursor - start) - x).trim();
} catch (ClassNotFoundException e) {
throw new CompileException("cannot resolve identifier: " + tk, condition, start);
}
}
// this.start = ++cursor;
this.start = cursor + 1;
this.offset = offset - (cursor - start) - 1;
if ((fields & COMPILE_IMMEDIATE) != 0) {
Class egress = (this.condition = (ExecutableStatement) subCompileExpression(expr, this.start, this.offset, pCtx)).getKnownEgressType();
if (itemType != null && egress.isArray()) {
enforceTypeSafety(itemType, getBaseComponentType(this.condition.getKnownEgressType()));
} else if (pCtx.isStrongTyping()) {
determineIterType(egress);
}
}
}
Aggregations