@@ -490,13 +490,12 @@ Boolean b = simple.booleanList.get(0);
490
490
<section xml : id =" expressions-ref-literal" >
491
491
<title >Literal expressions</title >
492
492
493
- <para >The types of literal expressions supported are strings, dates,
494
- numeric values (int, real, and hex), boolean and null. Strings are
495
- delimited by single quotes. To put a single quote itself in a string use
496
- two single quote characters. The following listing shows simple usage of
497
- literals. Typically they would not be used in isolation like this, but
498
- as part of a more complex expression, for example using a literal on one
499
- side of a logical comparison operator.</para >
493
+ <para >The types of literal expressions supported are strings, numeric values
494
+ (int, real, hex), boolean and null. Strings are delimited by single quotes.
495
+ To put a single quote itself in a string, use two single quote characters.
496
+ The following listing shows simple usage of literals. Typically they would not
497
+ be used in isolation like this but rather as part of a more complex expression,
498
+ for example using a literal on one side of a logical comparison operator.</para >
500
499
501
500
<programlisting language =" java" >ExpressionParser parser = new SpelExpressionParser();
502
501
@@ -626,8 +625,8 @@ int[][] numbers3 = (int[][]) parser.parseExpression("new int[4][5]").getValue(co
626
625
String c = parser.parseExpression("'abc'.substring(2, 3)").getValue(String.class);
627
626
628
627
// evaluates to true
629
- boolean isMember = parser.parseExpression("isMember('Mihajlo Pupin')").getValue(societyContext,
630
- Boolean.class); </programlisting >
628
+ boolean isMember = parser.parseExpression("isMember('Mihajlo Pupin')").getValue(societyContext, Boolean.class);
629
+ </programlisting >
631
630
</section >
632
631
633
632
<section xml : id =" expressions-operators" >
@@ -640,15 +639,24 @@ boolean isMember = parser.parseExpression("isMember('Mihajlo Pupin')").getValue(
640
639
or equal, greater than, and greater than or equal are supported using
641
640
standard operator notation.</para >
642
641
643
- <para >< programlisting language =" java" >// evaluates to true
642
+ <programlisting language =" java" >// evaluates to true
644
643
boolean trueValue = parser.parseExpression("2 == 2").getValue(Boolean.class);
645
644
646
645
// evaluates to false
647
646
boolean falseValue = parser.parseExpression("2 < -5.0").getValue(Boolean.class);
648
647
649
648
// evaluates to true
650
- boolean trueValue = parser.parseExpression("'black' < 'block'").getValue(Boolean.class);</programlisting >
651
- In addition to standard relational operators SpEL supports the
649
+ boolean trueValue = parser.parseExpression("'black' < 'block'").getValue(Boolean.class);
650
+ </programlisting >
651
+
652
+ <para >Greater/less-than comparisons against `null` follow a simple rule: `null`
653
+ is treated as nothing here (i.e. NOT as zero). As a consequence, any other value
654
+ is always greater than `null` (`X > null` is always `true`) and no other value
655
+ is ever less than nothing (`X < null` is always `false`). If you prefer numeric
656
+ comparisons instead, please avoid number-based `null` comparisons in favor of
657
+ comparisons against zero (e.g. `X > 0` or `X < 0`).</para >
658
+
659
+ <para >In addition to standard relational operators SpEL supports the
652
660
'instanceof' and regular expression based 'matches' operator.</para >
653
661
654
662
<programlisting language =" java" >// evaluates to false
@@ -661,14 +669,13 @@ boolean trueValue =
661
669
//evaluates to false
662
670
boolean falseValue =
663
671
parser.parseExpression("'5.0067' matches '^-?\\d+(\\.\\d{2})?$'").getValue(Boolean.class);
672
+ </programlisting >
664
673
665
- </programlisting >
666
- <para >Each symbolic operator can also be specified as a purely alphabetic equivalent. This avoids
667
- problems where the symbols used have special meaning for the document type in which
668
- the expression is embedded (eg. an XML document). The textual equivalents are shown
669
- here: lt ('< '), gt ('> '), le ('< ='), ge ('> ='),
670
- eq ('=='), ne ('!='), div ('/'), mod ('%'), not ('!').
671
- These are case insensitive.</para >
674
+ <para >Each symbolic operator can also be specified as a purely alphabetic equivalent.
675
+ This avoids problems where the symbols used have special meaning for the document type
676
+ in which the expression is embedded (eg. an XML document). The textual equivalents are
677
+ shown here: lt ('< '), gt ('> '), le ('< ='), ge ('> ='), eq ('=='), ne ('!='),
678
+ div ('/'), mod ('%'), not ('!'). These are case insensitive.</para >
672
679
</section >
673
680
674
681
<section xml : id =" expressions-operators-logical" >
0 commit comments