Object recipientValue = null;
try {
if (recipient != null) {
recipientValue = recipient.interpret(helper);
if (recipientValue == null) {
throw new ExecuteException("MethodExpression.interpret : null recipient for method " + token.getText() + getPos());
}
}
int argCount = arguments.size();
Object[] argValues = new Object[argCount];
for (int i = 0; i < argCount; i++) {
argValues[i] = arguments.get(i).interpret(helper);
}
// we have to enable triggers whenever we call out to a method in case it contians a trigger point
// TODO - do we do this if the method is a built-in? i.e. if the target is an instance of the helper class
// TODO - this breaks the user disable option so fix it!
Rule.enableTriggersInternal();
return method.invoke(recipientValue, argValues);
} catch (InvocationTargetException e) {
Throwable th = e.getCause();
if (th instanceof ExecuteException) {
throw (ExecuteException)th;
} else {
throw new ExecuteException("MethodExpression.interpret : exception invoking method " + token.getText() + getPos(), th);
}
} catch (ExecuteException e) {
throw e;
} catch (Exception e) {
throw new ExecuteException("MethodExpression.interpret : exception invoking method " + token.getText() + getPos(), e);
} finally {
// disable triggers again
Rule.disableTriggersInternal();
}
}