Service Logic Expressions

Introduction

Instead of providing a literal or  a single variable an expression can be provided. These can prove to be useful in switch statements.

This tutorial assumes you are familiar with escaping xml if this is a new concept please visit Escaping Xml.

The valid operators are specified in the grammar which can be found in gerrit.

All expressions begin and end with backticks. They may contain literals, variables and operators.

Logical Operators

operators

and or

example code

<switch test="`'PIZZA' == 'NOTPIZZA' or $a != $b`"> <switch test="`'PIZZA' == 'PIZZA' and $a != $b`"> <switch test="`'PIZZA' == 'NOTPIZZA' or $a &gt;= $b`"> <switch test="`'PIZZA' == 'PIZZA' and $b &lt; $a`">

log statements

2017-03-16T19:28:54.011Z|d1910234-d180-44c9-a33e-5b7095d272b9|qtp768791817-241|DEBUG|SetNodeExecutor |144 - com.att.sdnctl.sli-provider - 11.0.7.SNAPSHOT|Setting context attribute b to 3 2017-03-16T19:28:54.011Z|d1910234-d180-44c9-a33e-5b7095d272b9|qtp768791817-241|DEBUG|SetNodeExecutor |144 - com.att.sdnctl.sli-provider - 11.0.7.SNAPSHOT|Setting context attribute a to 5 2017-03-16T19:29:27.320Z|d1910234-d180-44c9-a33e-5b7095d272b9|qtp768791817-241|DEBUG|SwitchNodeExecutor |144 - com.att.sdnctl.sli-provider - 11.0.7.SNAPSHOT|test expression (PIZZA == NOTPIZZA or $a != $b) evaluates to true 2017-03-16T19:29:27.320Z|d1910234-d180-44c9-a33e-5b7095d272b9|qtp768791817-241|DEBUG|SwitchNodeExecutor |144 - com.att.sdnctl.sli-provider - 11.0.7.SNAPSHOT|test expression (PIZZA == PIZZA and $a != $b) evaluates to true 2017-03-16T19:47:34.510Z|d1910234-d180-44c9-a33e-5b7095d272b9|qtp768791817-241|DEBUG|SwitchNodeExecutor |144 - com.att.sdnctl.sli-provider - 11.0.7.SNAPSHOT|test expression (PIZZA == NOTPIZZA or $a >= $b) evaluates to true 2017-03-16T19:47:34.510Z|d1910234-d180-44c9-a33e-5b7095d272b9|qtp768791817-241|DEBUG|SwitchNodeExecutor |144 - com.att.sdnctl.sli-provider - 11.0.7.SNAPSHOT|test expression (PIZZA == PIZZA and $b < $a) evaluates to true

Comparison Operators

operators

example code

log statements

Arithmetic Operators

operators

example code

log statements

Concatentation

operators

sample code

log statements

Notes

If the + operator is used against numeric operands they are added. If the + operator is used against string operands they are concatenated.

If you need to concatenate strings which are numbers use StringUtils concat.

log statements