public class NativeExpressionEngine implements ExpressionEngine {
public ExpressionResult evaluateExpression(String expression, TMLContext context, int type, Map objects) {
WGDocument doc = context.getapiobject();
if (!doc.getDatabase().hasFeature(WGDatabase.FEATURE_NATIVEEXPRESSIONS)) {
return new ExpressionResult(null, false, false, new WGExpressionException("This database does not support native expressions", expression));
}
Object result = null;
try {
result = doc.evaluateExpression(expression);
}
catch (WGExpressionException e) {
return new ExpressionResult(null, false, true, e);
}
catch (WGAPIException e) {
return new ExpressionResult(null, false, true, new WGExpressionException(e.getMessage(), expression, e));
}
return new ExpressionResult(result, doc.resultIsTrue(result), doc.resultIsFalse(result), null);
}