首页 > 编程知识 正文

qlexpress 介绍,qlexpress可以序列化吗

时间:2023-05-06 03:06:20 阅读:274391 作者:4484

目录

目录编译脚本,查询外部需要定义的变量和函数 测试案例 关于不定参数的使用导航

编译脚本,查询外部需要定义的变量和函数

注意以下脚本int和没有int的区别

测试案例 compileScriptTest() /** * 注意以下脚本int和没有int的区别 * 备注:定义 int,则不包含平均分 * * @throws Exception if any */@Testpublic void compileScriptTest() throws Exception { String express = "int 平均分 = (语文+数学+英语+综合考试.科目2)/4.0;return 平均分"; ExpressRunner runner = new ExpressRunner(true, false); String[] names = runner.getOutVarNames(express); for (String s : names) { System.out.println("var : " + s); }} 测试结果 var : 数学var : 综合考试var : 英语var : 语文 关于不定参数的使用 /** * 动态参数测试 * @throws Exception if any */@Testpublic void dynamicVarTest() throws Exception { ExpressRunner runner = new ExpressRunner(); IExpressContext<String,Object> expressContext = new DefaultContext<>(); runner.addFunctionOfServiceMethod("getTemplate", this, "getTemplate", new Class[]{Object[].class}, null); //(1)默认的不定参数可以使用数组来代替 Object r = runner.execute("getTemplate([11,'22',33L,true])", expressContext, null,false, false); Assert.assertEquals("11,22,33,true,", r); //(2)像java一样,支持函数动态参数调用,需要打开以下全局开关,否则以下调用会失败 DynamicParamsUtil.supportDynamicParams = true; r = runner.execute("getTemplate(11,'22',33L,true)", expressContext, null,false, false); Assert.assertEquals("11,22,33,true,", r);} 导航

QLExpress 系列导航

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。