电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

运用BeanShell脚本语言进行逻辑判断

5页
  • 卖家[上传人]:宝路
  • 文档编号:21626482
  • 上传时间:2017-11-24
  • 文档格式:DOC
  • 文档大小:81.32KB
  • / 5 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、运用BeanShell 脚本语言进行逻辑判断Wang,XinyuBAS-DIT-Javaxin-Proprietary NoticeThis documentation is the property of, and contains confidential information of, Hewlett-Packard Company or its affiliates. Possession and use of this documentation is authorized only as specified in Exhibit SS5 and the HP Terms and Conditions of Sale and Services, HP Business Terms or HP Global Agreement or pursuant to the license accompanying this documentation. Keyword BeanSshell Category Java Description 运用BeanShell 脚本语言进行逻辑判断

      2、 How to Use IT 1. 简述: BeanShell是一种脚本语言,一种完全符合Java语法的java脚本语言,并且又拥有自己的一些语法和方法,BeanShell是一种松散类型的脚本语言(这点和JS类似)。实际工程中可以与用BeanShell脚本语言完成所需的简单或复杂对象的逻辑判断下载地址:http:/www.beanshell.org2. 环境设置: 1)配置BeanShellA. 把;bsh-xx.jar放到$JAVA_HOME/jre/lib/ext文件夹下Bunix: export CLASSPATH=$CLASSPATH:bsh-xx.jarC Windows: set classpath %classpath%;bsh-xx.jar本文中使用的是方法A,将bsh-2.0b4.jar放到C:jdk1.5.0_15jrelibext目录下2)检测配置打开dos窗口,键入:java bsh.Console命令出现BeanShell图片代表设置成功,BeanShell开始运行3. 具体应用: 1)在Eclipse中建立工程TestBeanShell2)添加所需Java类

      3、文件建立Bsh1.java,此文件中记录用使用BeanShell编写的方法。建立Person.java,此文件记录一个简单Java类对象。建立ServiceContext.java,此文件记录一个复杂Java类对象。3)BeanShell方法实现详解Person.javapackage bhs.shell;public class Person private String pname;public Person()super();public String getPname() return pname;public void setPname(String pname) this.pname = pname;ServiceContext.javapackage bhs.shell;import java.util.HashMap;import java.util.Map;public class ServiceContext public static final String EVENT_ID = EVENT_ID; public static final String MESS

      4、AGE_ID = MESSAGE_ID;private Map context = new HashMap();public void setAttribute(String key, Object value) context.put(key, value);public Object getAttribute(String key) return context.get(key);public void removeAttribute(String key) context.remove(key);Bsh1.javapackage bhs.shell;import java.util.*;import bsh.EvalError;import bsh.Interpreter;import bsh.UtilEvalError;public class Bsh1 public static void main(String args) throws EvalError, UtilEvalError Bsh1.testBshSimpleType();Bsh1.testBshComplex

      5、Type();Bsh1.testBshComplexExpression();public static boolean testBshSimpleType() throws EvalError Interpreter i = new Interpreter(); / Construct an interpreterBoolean flag = false;i.set(input, 3);i.set(b, 7);/ Eval a statement and get the resultflag = (Boolean) i.eval(b input);System.out.print(Simple Type result: +flag+n);return flag;public static boolean testBshComplexType()throws EvalError, UtilEvalError ServiceContext context = new ServiceContext();List list= new ArrayList();Person p1=new Per

      6、son();p1.setPname(eva);Person p2=new Person();p2.setPname(jason);list.add(p1);list.add(p2);context.setAttribute(input, list);Boolean flag = false;flag=(Boolean)validateCondition(Person)context.getAttribute(input).get(1).getPname().equals(jason), context);System.out.print(Complex Type result: +flag+n);return flag;public static boolean testBshComplexExpression()throws EvalError, UtilEvalErrorServiceContext context = new ServiceContext();context.setAttribute(a, 3);context.setAttribute(b, 4);context

      7、.setAttribute(c, 6);context.setAttribute(d, null);Boolean flag = false;flag=(Boolean) validateCondition(int)context.getAttribute(a)(int)context.getAttribute(b)&(context.getAttribute(d)=null),context);System.out.print(Complex Expression result: +flag+n);return flag;public static boolean validateCondition(String condition, ServiceContext context) throws EvalError, UtilEvalErrorInterpreter i = new Interpreter();/ construct an InterpreterBoolean flag = false;/ record the result expression estimatedi.getNameSpace().importPackage(bhs.shell);/ import whole package or import special class with importClass(Person.class.getName()i.set(context, context);flag = (Boolean) i.eval(condition);return flag;

      《运用BeanShell脚本语言进行逻辑判断》由会员宝路分享,可在线阅读,更多相关《运用BeanShell脚本语言进行逻辑判断》请在金锄头文库上搜索。

      点击阅读更多内容
    最新标签
    监控施工 信息化课堂中的合作学习结业作业七年级语文 发车时刻表 长途客运 入党志愿书填写模板精品 庆祝建党101周年多体裁诗歌朗诵素材汇编10篇唯一微庆祝 智能家居系统本科论文 心得感悟 雁楠中学 20230513224122 2022 公安主题党日 部编版四年级第三单元综合性学习课件 机关事务中心2022年全面依法治区工作总结及来年工作安排 入党积极分子自我推荐 世界水日ppt 关于构建更高水平的全民健身公共服务体系的意见 空气单元分析 哈里德课件 2022年乡村振兴驻村工作计划 空气教材分析 五年级下册科学教材分析 退役军人事务局季度工作总结 集装箱房合同 2021年财务报表 2022年继续教育公需课 2022年公需课 2022年日历每月一张 名词性从句在写作中的应用 局域网技术与局域网组建 施工网格 薪资体系 运维实施方案 硫酸安全技术 柔韧训练 既有居住建筑节能改造技术规程 建筑工地疫情防控 大型工程技术风险 磷酸二氢钾 2022年小学三年级语文下册教学总结例文 少儿美术-小花 2022年环保倡议书模板六篇 2022年监理辞职报告精选 2022年畅想未来记叙文精品 企业信息化建设与管理课程实验指导书范本 草房子读后感-第1篇 小数乘整数教学PPT课件人教版五年级数学上册 2022年教师个人工作计划范本-工作计划 国学小名士经典诵读电视大赛观后感诵读经典传承美德 医疗质量管理制度 2
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.