Operators"

From Documentation
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{ZUMLReferencePageHeader}}
 
{{ZUMLReferencePageHeader}}
  
EL expressions provide the following operators:
+
EL expressions provide the following operators<ref>The information is from [http://download.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html JSP Tutorial].</ref>:
  
{| border='1px'
+
{| class='wikitable'
! Type !! Description
+
! Type !! Operators !! Description
 
|-
 
|-
 
| Arithmetic
 
| Arithmetic
 
| +, -<ref>binary</ref>, *, /, div, %, mod, -<ref>unary</ref>
 
| +, -<ref>binary</ref>, *, /, div, %, mod, -<ref>unary</ref>
 +
|
 +
* / and div are the same, while % and mod are the same.
 
|-
 
|-
 
| Logical
 
| Logical
| and, <nowiki>&&</nowiki>, or, <nowiki>||</nowiki>, not, !, empty<ref>The empty operator is a prefix operation that can be used to determine whether a value is null or empty.</ref>
+
| and, <nowiki>&&</nowiki>, or, <nowiki>||</nowiki>, not, !, empty
 +
|
 +
* The empty operator is a prefix operation that can be used to determine whether a value is null or empty, such as ${empty foo}.
 
|-
 
|-
| Relational<ref>Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.</ref>
+
| Relational
 
|  ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le
 
|  ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le
 +
|
 +
* Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.
 
|-
 
|-
 
| Conditional
 
| Conditional
| A ? B : C<ref>Evaluate B or C, depending on the result of the evaluation of A.</ref>
+
| A ? B : C
 +
| It evaluate B or C, depending on the result of the evaluation of A.
 +
|-
 +
| Index
 +
| []
 +
|
 +
To evaluate expr-a[expr-b], evaluate expr-a into value-a and evaluate expr-b into value-b. If either value-a or value-b is null, return null.
 +
 
 +
* If value-a is a Map, return value-a.get(value-b). If !value-a.containsKey(value-b), then return null.
 +
* If value-a is a List or array, coerce value-b to int and return value-a.get(value-b) or Array.get(value-a, value-b), as appropriate. If the coercion couldn't be performed, an error is returned. If the get call returns an IndexOutOfBoundsException, null is returned. If the get call returns another exception, an error is returned.
 +
* If value-a is a JavaBeans object, coerce value-b to String. If value-b is a readable property of value-a, then return the result of a get call. If the get method throws an exception, an error is returned.
 +
|-
 +
| Member
 +
| .
 +
|
 +
* Properties of variables are accessed using the . operator and can be nested arbitrarily.
 +
* The value of a map can be accessed by using the . operator.
 
|}
 
|}
 
<blockquote>
 
<blockquote>
Line 23: Line 45:
 
</blockquote>
 
</blockquote>
  
The precedence of operators highest to lowest, left to right is as follows:
+
The relative precedence levels of operators from the highest to lowest, left to right are as follows:
  
 
* [] .
 
* [] .
* () - Used to change the precedence of operators.
+
* ()<ref>Used to change the precedence of operators.</ref>
* - (unary) not ! empty
+
* - <ref>unary</ref> not ! empty
 
* * / div % mod
 
* * / div % mod
* + - (binary)
+
* + - <ref>binary</ref>
 
* < > <= >= lt gt le ge
 
* < > <= >= lt gt le ge
 
* == != eq ne
 
* == != eq ne
Line 35: Line 57:
 
* || or
 
* || or
 
* ? :
 
* ? :
 +
 +
<blockquote>
 +
----
 +
<references/>
 +
</blockquote>
  
 
=Version History=
 
=Version History=

Latest revision as of 09:41, 1 June 2022

EL expressions provide the following operators[1]:

Type Operators Description
Arithmetic +, -[2], *, /, div, %, mod, -[3]
  • / and div are the same, while % and mod are the same.
Logical and, &&, or, ||, not, !, empty
  • The empty operator is a prefix operation that can be used to determine whether a value is null or empty, such as ${empty foo}.
Relational ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le
  • Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.
Conditional A ? B : C It evaluate B or C, depending on the result of the evaluation of A.
Index []

To evaluate expr-a[expr-b], evaluate expr-a into value-a and evaluate expr-b into value-b. If either value-a or value-b is null, return null.

  • If value-a is a Map, return value-a.get(value-b). If !value-a.containsKey(value-b), then return null.
  • If value-a is a List or array, coerce value-b to int and return value-a.get(value-b) or Array.get(value-a, value-b), as appropriate. If the coercion couldn't be performed, an error is returned. If the get call returns an IndexOutOfBoundsException, null is returned. If the get call returns another exception, an error is returned.
  • If value-a is a JavaBeans object, coerce value-b to String. If value-b is a readable property of value-a, then return the result of a get call. If the get method throws an exception, an error is returned.
Member .
  • Properties of variables are accessed using the . operator and can be nested arbitrarily.
  • The value of a map can be accessed by using the . operator.

  1. The information is from JSP Tutorial.
  2. binary
  3. unary

The relative precedence levels of operators from the highest to lowest, left to right are as follows:

  • [] .
  • ()[1]
  • - [2] not ! empty
  • * / div % mod
  • + - [3]
  • < > <= >= lt gt le ge
  • == != eq ne
  • && and
  • || or
  • ? :

  1. Used to change the precedence of operators.
  2. unary
  3. binary

Version History

Last Update : 2022/06/01


Version Date Content
     



Last Update : 2022/06/01

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.