本文整理匯總了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);
}
}
}