MVEL 2.0 Control Flow
MVEL's power goes beyond simple expressions. In fact, MVEL supports an
assortment of control flow operators which will allow you to perform advanced
scripting operations.
If-Then-Else
MVEL supports full, C/Java-style if-then-else blocks. For example:
if (var > 0) {
System.out.println("Greater than zero!");
}
else if (var == -1) {
System.out.println("Minus one!");
}
else {
System.out.println("Something else!");
}
Ternary statements
Ternary statements are supported just as in Java:
And nested ternary statements:
var > 0 ? "Yes" : (var == -1 ? "Minus One!" : "No")
Foreach
One of the most powerful features in MVEL is it's foreach operator. It
is similar to the for each operator in Java 1.5 in both syntax and
functionality. It accepts two parameters separated by a colon, the first is the
local variable for the current element, and the second is the collection or
array to be iterated.
For example:
count = 0;
foreach (name : people) {
count++;
System.out.println("Person #" + count + ":" + name);
}
System.out.println("Total people: " + count);
Since MVEL treats Strings as iterable objects you can iterate a String
(character by character) with a foreach block:
str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
foreach (el : str) {
System.out.print("[" + el + "]");
}
The above example outputs:
[A][B][C][D][E][F][G][H][I][J][K][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y][Z]
You can also use MVEL to count up to an integer value (from 1):
foreach (x : 9) {
System.out.print(x);
}
Which outputs: 123456789
Syntax Note: As of MVEL 2.0, it is now possible to simply abbreviate
foreach in the same way it is in Java 5.0, by using the
for keyword. For example:
for (item : collection) { ... }
For Loop
MVEL 2.0 implements standard C for-loops:
for (int i =0; i < 100; i++) {
System.out.println(i);
}
Do While, Do Until
do while and do until are implemented in
MVEL, following the same convention as Java, with until being
the inverse of while.
do {
x = something();
}
while (x != null);
... is semantically equivalent to ...
do {
x = something();
}
until (x == null);
While, Until
MVEL 2.0 implements standard while, with the addition of the
inverse until.
while (isTrue()) {
doSomething();
}
... or ...
until (isFalse()) {
doSomething();
}
分享到:
相关推荐
用于测试和演示 资源文件, ts类型,编码格式为avs2.0,文件大小为70M。
oauth-ng, 针对 OAuth 2.0隐式流的AngularJS指令 面向 OAuth 2.0 的 AngularJS指令 用于 OAuth 2.0隐式流处理器的AngularJS指令。文档 fork 在github上发送 repo 请求并发送带有主题分支的请求请求。 不要忘了为你的...
介绍USB2.0协议以及Cypress公司推出的USB2.0控制器CY7C68013。USB2.0协议提供480Mb/s的传输速度,向下完全兼容流行的USB1.1协议。CY7C68013是USB2.0的完整解决方案。该芯片包括带8.5KB片上RAM的高速8051单片机、4KB ...
angular-oauth, 客户端( 隐式授权) OAuth gnu 2.0授权流 这里项目提供客户端( 隐式授权) OAuth 2.0授权流的实现。特性使用基于的Token.getTokenByPopup() 函数检索用户的令牌,将用户提供授权终结点并异步返回令牌。...
特征工作流程工作流程引擎和领域模型过程一些与Workflow对象一起使用的接口定义BPMN 2.0流程定义坚持不懈序列化/反序列化Workflow对象的接口支持的工作流程元素连接对象顺序流流对象活动任务服务任务发送任务大事记...
NULL 博文链接:https://stonecold1108.iteye.com/blog/712460
基于消息语义提出一种分析UML2.0顺序图控制流的方法,分析了UML2.0顺序图消息发送和接收动作之间的关系,并将其映射到相应的消息上,得到消息的相继顺序关系.根据消息的顺序关系设计了由顺序图到活动图的一致性映射...
摘要:介绍USB2.0协议以及Cypress公司推出的USB2.0控制器CY7C68013。USB2.0协议提供480Mb/s的传输速度,向下完全兼容流行的USB1.1协议。CY7C68013是USB2.0的完整解决方案。该芯片包括带8.5KB片上RAM的高速8051单片机...
waterfall瀑布流.rar
基于“移动全球眼”平台的Web2.0业务探讨,月球,,本文总结了web 2.0的应用现状及国内外业务发展的情况,深入分析探讨了运营商对于移动互联网web 2.0业务可采取的应用模式、重点介绍了�
流媒体服务器(v2.0)
花瓣petal主题是一款瀑布流WordPress主题,主题清新简洁。瀑布流是今年流行的一种页面布局方式,...主题名称:petal_2.0仿花瓣瀑布流布局(瀑布流主题) 主题版本:2.0 主题作者:空杯 主题插件:推荐安装WP-PostViews
《深入理解Yii2.0》是一本干货。主要讲解Yii2.0及所代表的最新一代Web开发框架的新特性、新技术、新理念、新模式。 采用的方式是分析框架的源代码,尝试从根上进行理解和阐述,并融入个人使用Yii开发的一些经验和...
通过控制流混淆保护的程序集的运行时性能得到改进 改进了交叉装配混淆 更新了Visual Studio加载项 改进了运行时许可检查性能 修复了Unity 3D保护问题 修复了数字证书签名问题 修复了LINQ混淆问题 修复了小错误
很难找的工作流中文标准,尤其是2.0很少很少。希望能帮到大家研究。
18、Silverlight(20) - 2.0通信之WebClient, 以字符串的形式上传/下载数据, 以流的方式上传/下载数据 19、Silverlight(21) - 2.0通信之WebRequest和WebResponse, 对指定的URI发出请求以及接收响应 20、Silverlight...
WAP 2.0 开发环境教程,对于现在越来越流行的手机WAP开发有很大帮助!
这里较为详细的介绍了BPMN2.0: 1.1. BPMN 2.0是什么 ...1.8. 基本结构(事件、顺序流、网关、任务) 1.9. 高级结构(内嵌子流程、定时启动事件、中间事件、内部捕获事件) 1.10. 完全的实例(包括控制台任务表单)
在中国,虽然在网站运营中普遍推广WEB 2.0概念并以此作为新一轮网站竞争要点主要始于2005年,但关于WEB 2.0中一些相关应用(如博客)的关注从2002年左右就开始了。 在WEB 2.0的发展中,博客概念的推广以及博客网站的...
bpmn2.0规范的最终正式版,涵盖了状态机、协作流程、业务流程等等