@Override @SuppressWarnings("unchecked") public T evaluate() throws DDMExpressionException { try { com.udojava.evalex.Expression expression = new com.udojava.evalex.Expression(_expressionString); for (Map.Entry<String, Variable> entry : _variables.entrySet()) { BigDecimal variableValue = getVariableValue(entry.getValue()); expression.setVariable(entry.getKey(), variableValue); } BigDecimal result = evaluate(expression); return (T) toRetunType(result); } catch (Exception e) { throw new DDMExpressionException(e); } }
protected com.udojava.evalex.Expression getExpression(String expressionString) throws DDMExpressionException { com.udojava.evalex.Expression expression = new com.udojava.evalex.Expression(expressionString); TokenExtractor tokenExtractor = new TokenExtractor(expressionString); Map<String, String> variableMap = tokenExtractor.getVariableMap(); for (String key : variableMap.keySet()) { Variable variable = _variables.get(key); if (variable != null) { BigDecimal variableValue = getVariableValue(variable); expression.setVariable(key, variableValue); } } return expression; }