Common Template Engine English | 中文 | Translate  
Downloads News Forums About Us
Documents
Overview
Template Guide
Expression Guide
Integration Guide
Config Guide
API Use Guide
Expansibility Guide
Architecture Guide
Dependency Lib
FAQ
Resources
Downloads
Changes Log
License
UML
Java Doc
Coverage Report
Community
Developer Team
Developer Team
Forums
Mail List
Bugs List
Report Bugs Here !
Support
Common Expression Language(CEL) Guide


1. Expression Rule:
...

2. Standard Expression:
(1) getter:
. Property Getter, eg: ${user.name}
[] Index Getter, eg: ${user["name"]} ${user[nameVaribale]} ${items[1]} ${items[1..2]} ${items[1,2,4]}
[] Change to collection, eg: $for{num : [100]} $for{num : [name:value]}
(2) sequence:
: Entry Literal, eg: ${user.nameVar : "james"} ${name : "james"} Comment: variable key: ${$name : "james"}
.. Sequence Literal, eg: ${1..5} $for{seq : 1..5} $for{weekDay : "Sunday".."Saturday"}
, List Literal, eg: ${1,2,5,7} $for{seq : (1,2,5,7)}
:, Map Literal, eg: ${a : 100, b: 2, c : 7} $for{rel : (a : 100, b: 2, c : 7)}
(3) object:
== Value Equal Comparator , eg: ${user1 == user2}
!= Value Not Equal Comparator , eg: ${user1 != user2}
| Not Empty Selector , eg: ${user1 | user2} $for{user : (users1 | users2 | users3}
(4) boolean:
&& Logic And, eg: ${user1.agree && user2.agree}
|| Logic Or, eg: ${user1.agree || user2.agree}
! Logic Not, eg: ${! user1.agree}
?: Logic Select, eg: ${user1.agree ? "yes" : "no"}
(5) number:
+ Add Operator, eg: ${user1.coins + user2.coins}
- Subtract Operator, eg: ${user1.coins - user2.coins}
* Multiply Operator, eg: ${user.coins * 2}
/ Divide Operator, eg: ${user.coins / 2}
% Modulus Operator, eg: ${user.coins % 2}
> Greater Than Comparator, eg: ${user1.coins > user2.coins}
< Less Than Comparator, eg: ${user1.coins < user2.coins}
>= Greater Equal Comparator, eg: ${user1.coins >= user2.coins}
<= Less Equal Comparator, eg: ${user1.coins <= user2.coins}
~ Number Format, eg: ${user1.coins ~ "###,##0.###"}
(6) string:
+ String Concatenate, eg: ${user.firstname + user.lastname}
> Greater Than Comparator, eg: ${user1.name > user2.name}
< Less Than Comparator, eg: ${user1.name < user2.name}
>= Greater Equal Comparator, eg: ${user1.name >= user2.name}
<= Less Equal Comparator, eg: ${user1.name <= user2.name}
(7) date:
+ After Days, eg: ${user.registerDate + 3}
- Before Days, eg: ${user.registerDate - 3}
> Greater Than Comparator, eg: ${user1.registerDate > user2.registerDate}
< Less Than Comparator, eg: ${user1.registerDate < user2.registerDate}
>= Greater Equal Comparator, eg: ${user1.registerDate >= user2.registerDate}
<= Less Equal Comparator, eg: ${user1.registerDate <= user2.registerDate}
~ Date Format, eg: ${user.registerDate ~ "yyyy-MM-dd"}
(8) array,list,map:
+ List or Map Concatenate, eg: ${items + ("a","b")}

3. Property:
(1) boolean:
not, eg: ${true.not} ${user.allow.not}
(2) string:
capital , eg: ${"james".capital}
toDate, Convert To Date Type By "yyyy-MM-dd" Format, eg: $if{now > "2007-01-01".toDate}
toDateTime, Convert To Date Type By "yyyy-MM-dd HH:mm:ss" Format, eg: $if{now > "2007-01-01 23:10:05".toDateTime}
escapeHtml, eg: ${"<b>".escapeHtml}
toInteger, Convert To Integer Type, eg: ${"1".toInteger + 2}
toLong, Convert To Long Type, eg: ${"25".toInteger + 2}
toFloat, Convert To Float Type, eg: ${"1.2".toInteger + 2}
toDouble, Convert To Double Type, eg: ${"2.3".toInteger + 2}
(3) date:
year, month, day, hour, minute, second, millisecond Date parts getter, eg: ${createDate.day} ${createDate.hour}
dayInYear, eg: ${createDate.dayInYear}
week, eg: ${createDate.week}
era, eg: ${createDate.era}
century, eg: ${createDate.century}
timezone, eg: ${createDate.timezone}
leap, eg: $if{now.lenient}
toLong, compare with 1970-01-01 00:00:00.000, eg: ${createDate.toLong}
(4) long:
toDate, Long To Date, eg: ${9999999.toDate}

4. Sequence:
(1) Number: ${1 .. 20} ${20 .. -12}
(2) Letter: ${a .. z} ${z .. a} ${A .. Z} ${b .. k}
(3) Season: ${"Spring" .. "Winter"}
(4) Month: ${"January" .. "December"}
(5) Week: ${"Sunday" .. "Saturday"}


Copyright © 2007-2008 CommonTemplate Team