IKExpression
程序员文章站
2022-06-16 21:28:33
...
import java.util.ArrayList; import java.util.List; import org.wltea.expression.ExpressionEvaluator; import org.wltea.expression.datameta.BaseDataMeta.DataType; import org.wltea.expression.datameta.Variable; public class IKExpressionTest { public static void main(String[] args) { /*String expression = "\"AGE\" + age1 + (age2 / age3)"; List<Variable> variables = new ArrayList<Variable>(); Variable variable = new Variable("age1", DataType.DATATYPE_DOUBLE, 3); Variable variable2 = new Variable("age2", DataType.DATATYPE_DOUBLE, 4); Variable variable3 = new Variable("age3", DataType.DATATYPE_DOUBLE, 5); variables.add(variable); variables.add(variable2); variables.add(variable3); Object result = ExpressionEvaluator.evaluate(expression,variables); System.out.println(result); String expression2 = "1.0 +23-4"; Object result2 = ExpressionEvaluator.evaluate(expression2); System.out.println(result2); */ String expression = "item_13==3 || item_13==4"; List<Variable> variables = new ArrayList<Variable>(); Variable variable = new Variable("item_13", DataType.DATATYPE_INT, 3); variables.add(variable); Object result = ExpressionEvaluator.evaluate(expression,variables); System.out.println(result); } }
上一篇: js安全类型检测
下一篇: Linux使用zsh提高效率的5条建议
推荐阅读