Types of Literals

Use

Data Types

Data Types

Explanation

Integer Literal

Any numeric literal with no fraction is treated as Integer Literal. For example: 3, 27.

The default literal type for integer literal is int. You can designate an integer literal as long by suffixing 'l' or 'L' to the value. For example: 200L, 5000l

Floating Point Literal

Any numeric literal with fraction is considered as Floating type literal. Ex. 3.0, 27.0

You can also specify a floating point in scientific notation by using exponent 'E' or 'e'. For example: 0.03E2.

The default literal type for floating type literal is double. You can designate a literal as float by using the suffix 'f' or 'F'. For example: 200.0f, 5000.0F.

You can also represent a literal as double by the optional suffix 'd' or 'D'. For example: 3.0d, 27.0D

Boolean Literal

You can represent Boolean literals by using the keywords true and false.

Character Literal

You can represent a character literal by a single character delimited by single quotes. For example: 'a'

String Literal

String literal is a sequence of characters which has to be single quoted.

Date Literal

Date literal is a date representation in the xsd: date format yyyy-mm-dd within a single quote

Escape Character

The escape character is a character which provides alternate interpretation of a character in a character sequence. The escape character is backslash '\'

Identifiers

Variable Name

Each variable name is a sequence of characters delimited by double quotes

Aliases

Each alias name is a sequence of character delimited by double quotes.

Expressions and their Usage

Expression as Argument

An argument in an Alias Name can have expression. So an alias name can have literal or variable name as an argument.

Other Condition

A simple condition is a condition which has left and right expression with relational comparators in between. The list of comparators available are Equals, Not Equals, Greater Than Equals, Greater Than, Less Than Equals, Less Than, Like, Not Like, In and Not In. Ex.

Best Practices

  • You must avoid having Overloaded Alias name.

    When having overloaded alias name, the alias name resolved while creating the conditions object might map to a different alias from the one expected. The Java Language Specification is applied to resolve the method aliases.

  • You must always use suffixes to mark the type of the literal.

    An input of "Grant Loan(1000)" will always resolve to 'int' type as per the Literal definition. If the 'long' type has to be resolved the input should be "Grant Loan(1000L)". The suffix of long makes the parser to treat the literal as 'long' instead of the default numeric literal 'int' .

  • You must always use curly braces to group conditions.

    If you do not group conditions, then the Rules Composer will decide the grouping.