欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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);
	}
}

推荐阅读