Operators

The operators serve to create more complicated expressions within the program. They can be arithmetic, relational and logical. The relational and logical operators serve to create expressions with resulting boolean value. The arithmetic operators can be used in all expressions, not only the logical ones.

All operators can be grouped into three categories:

Arithmetic Operators

The following operators serve to put together values of different expressions (except those of boolean values). These signs can be used more times in one expression. In such a case, you can express priority of operations by parentheses. The result depends on the order of the expressions.

  • Addition

    +

    The operator above serves to sum the values of two expressions.

    But the addition of two boolean values or two date data types is not possible. To create a new value from two boolean values, you must use logical operators instead.

    Nevertheless, if you want to add any data type to a string, the second data type is converted to a string automatically and it is concatenated with the first (string) summand. But remember that the string must be on the first place! Naturally, two strings can be summed in the same way. Note also that the concat() function is faster and you should use this function instead of adding any summand to a string.

    You can also add any numeric data type to a date. The result is a date in which the number of days is increased by the whole part of the number. Again, here is also necessary to have the date on the first place.

    The sum of two numeric data types depends on the order of the data types. The resulting data type is the same as that of the first summand. The second summand is converted to the first data type automatically.

  • Subtraction and Unitary minus

    -

    The operator serves to subtract one numeric data type from another. Again the resulting data type is the same as that of the minuend. The subtrahend is converted to the minuend data type automatically.

    But it can also serve to subtract numeric data type from a date data type. The result is a date in which the number of days is reduced by the whole part of the subtrahend.

  • Multiplication

    *

    The operator serves only to multiplicate two numeric data types.

    Remember that during multiplication the first multiplicand determines the resulting data type of the operation. If the first multiplicand is an integer number and the second is a decimal, the result will be an integer number. On the other hand, if the first multiplicand is a decimal and the second is an integer number, the result will be of decimal data type. In other words, order of multiplicands is of importance.

  • Division

    /

    The operator serves only to divide two numeric data types. Remember that you must not divide by zero. Dividing by zero throws TransformLangExecutorRuntimeException or gives Infinity (in case of a number data type)

    Remember that during division the numerator determines the resulting data type of the operation. If the nominator is an integer number and the denominator is a decimal, the result will be an integer number. On the other hand, if the nominator is a decimal and the denominator is an integer number, the result will be of decimal data type. In other words, data types of nominator and denominator are of importance.

  • Modulus

    %

    The operator can be used for both floating-point data types and integer data types. It returns the remainder of division.

  • Incrementing

    ++

    The operator serves to increment numeric data type by one. The operator can be used for both floating-point data types and integer data types.

    If it is used as a prefix, the number is incremented first and then it is used in the expression.

    If it is used as a postfix, first, the number is used in the expression and then it is incremented.

  • Decrementing

    --

    The operator serves to decrement numeric data type by one. The operator can be used for both floating-point data types and integer data types.

    If it is used as a prefix, the number is decremented first and then it is used in the expression.

    If it is used as a postfix, first, the number is used in the expression and then it is decremented.

Relational Operators

The following operators serve to compare some subexpressions when you want to obtain a boolean value result. Each of the mentioned signs can be used. If you choose the .operator. signs, they must be surrounded by white spaces. These signs can be used more times in one expression. In such a case you can express priority of comparisons by parentheses.

  • Greater than

    Each of the two signs below can be used to compare expressions consisting of numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data type.

    • >
    • .gt.
  • Greater than or equal to

    Each of the three signs below can be used to compare expressions consisting of numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data type.

    • >=
    • =>
    • .ge.
  • Less than

    Each of the two signs below can be used to compare expressions consisting of numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data type.

    • <
    • .lt.
  • Less than or equal to

    Each of the three signs below can be used to compare expressions consisting of numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data type.

    • <=
    • =<
    • .le.
  • Equal to

    Each of the two signs below can be used to compare expressions of any data type. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data type.

    • ==
    • .eq.
  • Not equal to

    Each of the three signs below can be used to compare expressions of any data type. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data type.

    • !=
    • <>
    • .ne.
  • Matches regular expression

    The operator serves to compare string and some regular expression. The regular expression can look like this (for example): "[^a-d].*" It means that any character (it is expressed by the dot) except a, b, c, d (exception is expressed by the ^ sign) (a-d means - characters from a to d) can be contained zero or more times (expressed by *). Or, '[p-s]{5}' means that p, r, s must be contained exactly five times in the string. For more detailed explanation about how to use regular expressions see java.util.regex.Pattern.

    • ~=
    • .regex.
  • Contained in

    This operator serves to specify whether some value is contained in the list or in the map of other values.

    • .in.

Logical Operators

If the expression whose value must be of boolean data type is complicated, it can consist of some subexpressions (see above) that are put together by logical conjunctions (AND, OR, NOT, .EQUAL TO, NOT EQUAL TO). If you want to express priority in such an expression, you can use parentheses. From the conjunctions mentioned below you can choose either form (for example, && or and, etc.).

Every sign of the form .operator. must be surrounded by white space.

  • Logical AND

    • &&
    • and

  • Logical OR

    • ||
    • or

  • Logical NOT

    • !
    • not

  • Logical EQUAL TO

    • ==
    • .eq.

  • Logical NOT EQUAL TO

    • !=
    • <>
    • .ne.