Posted on 2010-01-06 00:44
leekiang 阅读(1109)
评论(0) 编辑 收藏 所属分类:
java
JEP
http://www.singularsys.com/jep/
https://sourceforge.net/projects/jep/
http://rabbit8.bokee.com/3936531.html
http://suneca.com/article.asp?id=28
http://www.javaeye.com/topic/58422里办法多
关于jexl
1,jexl1.1计算分母为0的表达式时,竟然算出来的值为0,被某人说没有逻辑https://issues.apache.org/jira/browse/JEXL-45
2,jexl2解决了这个问题,但jexl2依赖jdk5
https://issues.apache.org/jira/browse/JEXL-58
handles ArithmeticException (divide by zero)
division by zero ignored only if JexlEngine.isSilent()
JexlEngine jexl = new JexlEngine();
jexl.setCache(512);//有何用
jexl.setLenient(false);//什么意思
jexl.setSilent(false);
String calculate = "(G1 + G2)/2";
Expression e =jexl.createExpression(calculate);
// populate the context
JexlContext context = new MapContext();
context.set("G1", "3");
context.set("G2", "5");
Object res = e.evaluate(context);//silent为false时evaluate方法会抛异常,为true不抛异常但res为null
另外,利用oracle计算,如果分母为0会报ORA-01476: divisor is equal to zero