Start page / Template development / Template syntax / Expressions / Constants

Constants

Evaluation of constant expressions

The simplest type of expressions is direct value input for different data types:

  • Strings
  • Numbers
  • Truth values
  • Lists
  • Sets
  • Maps

String constants

"That is a text."
"That is a text with \"quotation marks\"!"

In the constants given above one direct value each is given, in this case a character string.

In combination with an instruction, for example:

$CMS_SET(varName, "That is a text.")$

a string object is generated from the constant. The expression:

$CMS_VALUE("That is a text.".class)$

therefore produces the following output:

java.lang.String

In combination with the instruction $CMS_VALUE(...)$

$CMS_VALUE("That is a text with \"quotation marks\"!")$

the expression produces the following output:

That is a text with "quotation marks"!.

Number constant

42
3.1333

In the constants given above one direct value each is given, in this case a number.

In combination with an instruction, for example:

$CMS_SET(42)$

an integer object is generated from the constant. The expression:

$CMS_VALUE(42.class)$

therefore produces the following output:

java.math.BigInteger

or the expression:

$CMS_VALUE(3.1333.class)$

the output:

java.math.BigDecimal

Boolean constant

true
false

In the constants given above a direct value is specified for each, in this case a Boolean expression which is true (or '1') or false (or '0'). In combination with an instruction, for example:

$CMS_SET(true)$

a Boolean object is generated from the constant. The expression:

$CMS_VALUE(true.class)$

therefore produces the following output:

java.lang.Boolean

List constant

In the expressions given below direct values are passed to the elements of a List .

In the first case three string objects "a", "b", "c" are passed:

["a", "b", "c"] 

In the second case, 10 integer objects are passed. This type of expression, which defines an ascending or descending series 'from' a start element 'up to' an end element, is possible for Lists only:

[1..10]

The expression given above generates a list with number elements 1 to 10 and is thus evaluated analogous to:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

.

Different types of data can of course also be passed. An expression in the following form:

[1, "a", false, 43.5]

generates list elements of the following data types:

java.math.BigInteger, java.lang.String, java.lang.Boolean, java.math.BigDecimal

Map constant

In the expressions given below direct key value pairs are passed to the individual map elements:

{1:"alpha", "3":3, true:true}

In the code example given above three key value pairs are generated with the following key values:

  • 1 (of integer type)
  • "3" (of string type)
  • true (of Boolean type)

and the values:

  • "alpha" (of string type)
  • 3 (of integer type)
  • true (of Boolean type)

Set constant

In the expressions given below, direct values are passed to the individual set elements.

In the first case three string objects "a", "b", "c" are passed:

{"a", "b", "c"}

In the second case, 3 integer objects are passed.

{1, 45, 10}

Different types of data can of course also be passed. An expression in the following form:

[1, "a", false, 43.5]

generates elements of the following data types:

java.math.BigInteger, java.lang.String, java.lang.Boolean, java.math.BigDecimal

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.4 | Data privacy