本文整理汇总了Java中com.googlecode.aviator.AviatorEvaluator类的典型用法代码示例。如果您正苦于以下问题:Java AviatorEvaluator类的具体用法?Java AviatorEvaluator怎么用?Java AviatorEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AviatorEvaluator类属于com.googlecode.aviator包,在下文中一共展示了AviatorEvaluator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.googlecode.aviator.AviatorEvaluator; //导入依赖的package包/类
public static Object execute(final String expression, final Map<String, Object> context) {
Object value = null;
try {
final Expression compiledExp = AviatorEvaluator.compile(expression, true);
value = compiledExp.execute(context);
} catch (final ExpressionRuntimeException ex) {
logger.error(ex.getMessage());
}
return value;
}
示例2: filter
import com.googlecode.aviator.AviatorEvaluator; //导入依赖的package包/类
public boolean filter(CanalEntry.Entry entry) throws CanalFilterException {
if (StringUtils.isEmpty(expression)) {
return true;
}
Map<String, Object> env = new HashMap<String, Object>();
env.put(ROOT_KEY, entry);
return (Boolean) AviatorEvaluator.execute(expression, env);
}
示例3: main
import com.googlecode.aviator.AviatorEvaluator; //导入依赖的package包/类
public static void main(String[] args) {
List<String> symble = Lists.newArrayList("+", "-", "*", "/","%","^");
for (String s1 : symble) {
for (String s2 : symble) {
String expression = "4" + s1 + "4" + s2 + "4";
Object exec = AviatorEvaluator.exec(expression);
System.out.println(expression + "=" + exec);
}
}
}