@@ -744,25 +744,42 @@ topics:
744744[[expressions-ref-literal]]
745745=== Literal Expressions
746746
747- The types of literal expressions supported are strings, numeric values (int, real, hex),
748- boolean, and null. Strings are delimited by single quotation marks. To put a single quotation mark itself
749- in a string, use two single quotation mark characters.
747+ SpEL supports the following types of literal expressions.
750748
751- The following listing shows simple usage of literals. Typically, they are not used
752- in isolation like this but, rather, as part of a more complex expression -- for example,
753- using a literal on one side of a logical comparison operator.
749+ - strings
750+ - numeric values: integer (`int` or `long`), hexadecimal (`int` or `long`), real (`float`
751+ or `double`)
752+ - boolean values: `true` or `false`
753+ - null
754+
755+ Strings can delimited by single quotation marks (`'`) or double quotation marks (`"`). To
756+ include a single quotation mark within a string literal enclosed in single quotation
757+ marks, use two adjacent single quotation mark characters. Similarly, to include a double
758+ quotation mark within a string literal enclosed in double quotation marks, use two
759+ adjacent double quotation mark characters.
760+
761+ Numbers support the use of the negative sign, exponential notation, and decimal points.
762+ By default, real numbers are parsed by using `Double.parseDouble()`.
763+
764+ The following listing shows simple usage of literals. Typically, they are not used in
765+ isolation like this but, rather, as part of a more complex expression -- for example,
766+ using a literal on one side of a logical comparison operator or as an argument to a
767+ method.
754768
755769[source,java,indent=0,subs="verbatim,quotes",role="primary"]
756770.Java
757771----
758772 ExpressionParser parser = new SpelExpressionParser();
759773
760- // evals to "Hello World"
774+ // evaluates to "Hello World"
761775 String helloWorld = (String) parser.parseExpression("'Hello World'").getValue();
762776
777+ // evaluates to "Tony's Pizza"
778+ String pizzaParlor = (String) parser.parseExpression("'Tony''s Pizza'").getValue();
779+
763780 double avogadrosNumber = (Double) parser.parseExpression("6.0221415E+23").getValue();
764781
765- // evals to 2147483647
782+ // evaluates to 2147483647
766783 int maxValue = (Integer) parser.parseExpression("0x7FFFFFFF").getValue();
767784
768785 boolean trueValue = (Boolean) parser.parseExpression("true").getValue();
@@ -774,22 +791,22 @@ using a literal on one side of a logical comparison operator.
774791----
775792 val parser = SpelExpressionParser()
776793
777- // evals to "Hello World"
794+ // evaluates to "Hello World"
778795 val helloWorld = parser.parseExpression("'Hello World'").value as String
779796
797+ // evaluates to "Tony's Pizza"
798+ val pizzaParlor = parser.parseExpression("'Tony''s Pizza'").value as String
799+
780800 val avogadrosNumber = parser.parseExpression("6.0221415E+23").value as Double
781801
782- // evals to 2147483647
802+ // evaluates to 2147483647
783803 val maxValue = parser.parseExpression("0x7FFFFFFF").value as Int
784804
785805 val trueValue = parser.parseExpression("true").value as Boolean
786806
787807 val nullValue = parser.parseExpression("null").value
788808----
789809
790- Numbers support the use of the negative sign, exponential notation, and decimal points.
791- By default, real numbers are parsed by using `Double.parseDouble()`.
792-
793810
794811
795812[[expressions-properties-arrays]]
@@ -804,15 +821,15 @@ Pupin's city of birth, we use the following expressions:
804821[source,java,indent=0,subs="verbatim,quotes",role="primary"]
805822.Java
806823----
807- // evals to 1856
824+ // evaluates to 1856
808825 int year = (Integer) parser.parseExpression("birthdate.year + 1900").getValue(context);
809826
810827 String city = (String) parser.parseExpression("placeOfBirth.city").getValue(context);
811828----
812829[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
813830.Kotlin
814831----
815- // evals to 1856
832+ // evaluates to 1856
816833 val year = parser.parseExpression("birthdate.year + 1900").getValue(context) as Int
817834
818835 val city = parser.parseExpression("placeOfBirth.city").getValue(context) as String
0 commit comments