QLExpress可以执行标准的java语法,例如 '哈哈'.equals('哈哈')、if(true) {1} else{2}等,可以动态获取运算结果。
QLExpress 3.0.6下载地址:http://code.taobao.org/p/QLExpress/file/2949/qlexpress-3.0.6.zip
wiki地址:http://code.taobao.org/p/QLExpress/wiki/index/
demo代码如下:
package com.test;
import com.ql.util.express.ExpressRunner; public class Test {
/**
*
* @return void
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String express1 = " 1 in (2) ";
String express2 = " if(false){ 1} else{2} ";
String express3 = " round(4.34,1) ";
String express4 = " '哈哈'.equals('哈哈') ";
ExpressRunner runner = new ExpressRunner(); System.out.println("表达式计算:" + express1 + " 处理结果: " + runner.execute(express1, null, null, false, false) );
System.out.println("表达式计算:" + express2 + " 处理结果: " + runner.execute(express2, null, null, false, false) );
System.out.println("表达式计算:" + express3 + " 处理结果: " + runner.execute(express3, null, null, false, false) );
System.out.println("表达式计算:" + express4 + " 处理结果: " + runner.execute(express4, null, null, false, false) ); }
}
代码运行截图:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsYAAAB/CAIAAABjUJN2AAAYI0lEQVR4nO2d24GrOgxFU1cKSj0p4VaRZlIM9yMJ+CHJsi0Cc7LW1wzYxpaFtDEELgsAAADANJejOwAAAAD/AkgKAAAACABJAQAAAAEgKQAAACAAJAUAAAAEgKQAAACAAJAUAAAAEACSAgAAAAJAUgAAAEAAB0mK5/16ud6fex7icdv7CLAsy7I8bpfbY5mb0y/4w7/HZrTPFPwamtts5/7zfv1DplF623V2cCrtz+N2abDO4vN+/bHZQFJsxVW3mCOLE49b2rDRx3d/PEWnezc30sMkxdtEar1kSrMB1qZ83q/h0x5O1snL9f6MkxRW4k0OW1ox2ZzYVPHUAAeumpiRFPmZKO5V3GHdp4/HZTTZDzslhdsm52YbuWw6xebVJGZhXDODNjsFlg8U5dQCTUXh7/C2c+u/UqH27WrI+11xOyXFGcR+Zx8GbTYWnfW+bT718ovbLSupulzZj51c4Hm/Xq9zczuczyKc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