Expressions in Parameters

An expression in a parameter definition can take one the following values:

The syntax for mathematical expressions is based primarily on Java syntax, although a few items use a proprietary syntax. When evaluating mathematical expressions, the SRC software:

The following sections describe how to format the items that you can use in an expression.

Specifying Parameter Names

Observe the following rules when you are specifying parameter names:

Formatting Numbers

Observe the following rules when you are formatting numbers:

Formatting Strings

Use Java syntax for strings; enclose strings in double quotation marks.

Example—“engineering”

Observe the following rules when you are formatting strings:

Using IPv4 Addresses

Use the following format for IP addresses:

<string>.<string>.<string>.<string> | ‘<string>.<string>.<string>.<string>’<string> is a set of digits in the range 0–255Example—‘192.0.2.1’

Single quotation marks around an item indicate that it represents an address; however, for IPv4 addresses, the quotation marks are optional.

Specifying Ranges

To specify a range of numbers, strings, and addresses, use two dots between the arguments.

Example—192.0.2.1..192.0.3.1

Formatting Lists

To specify a list of values, enclose a set of subordinate expressions separated by commas in a pair of square brackets.

Example—[ip, icmp, ftp]

Formatting Maps

Maps are used to specify values that have optional and interdependent attributes. For example, when you define an application object through the Enterprise Manager portal, you can select a number of attributes and specify particular values for them. Depending on the value of the attribute, other attributes are possible or required.

To format a map, specify a list of pairs of attributes and corresponding values. Separate the pairs with commas, and enclose the list in curly brackets (braces).

Example—{applicationProtocol="ftp” , sourcePort=123, inactivityTimeout=60}

Using Keywords

The SRC software ignores all Java keywords in substitutions, so that you can use Java keywords for identifiers such as variable names, function names, and attribute names in maps. The SRC software accepts one keyword, not, which is used to indicate conditions that do not match a specified value. For more information about the not keyword.

Using Separators

You cannot use a dot (.) as a separator. You can use other Java separators in the ways that Java supports.

Using Operators

Table 14 shows the operations and corresponding operators that the SRC software supports for substitutions. Most of the operators are Java operators, although a few operators are proprietary. You cannot use Java operators that do not appear in this table.

Table 14: Operations That You Can Use in Expressions

Operation

Operator

Number of Arguments

Result If Different from Java Conventions

Conditions for Evaluation

Example

Bitwise AND of the arguments

&

Two

 

Both arguments must be integers

234567 & 876543

Bitwise exclusive OR of the arguments

^

Two

 

Both arguments must be integers

234567 ^ 876543

Bitwise inclusive OR of the arguments

|

Two

 

Both arguments must be integers

234567 | 876543

Bitwise negation of the argument

~

One

 

Argument must be an integer

–234567

Difference between two arguments

Two

 

Both arguments must be numbers

876543 – 234567

Division of the first argument by the second argument

/

Two

Result of operation in double format

Both arguments must be numbers

589 / 756

Equal

==

Two

Nonzero number if the arguments are equal

Both arguments must be numbers

rate==5

Greater than

>

Two

Nonzero integer if the first argument is greater than the second argument

Both arguments must be numbers

rate>5

Greater than or equal to

>=

Two

Nonzero integer if the first argument is greater than or equal to the second argument

Both arguments must be numbers

rate>=5

If... then... else... operation

?:

Three

If the first argument is nonzero, then the result is the second argument, else the result is the third argument

First argument must be a number

“ x == 1 ? rate : 2*rate”

Less than

<

Two

Nonzero integer if the first argument is less than the second argument

Both arguments must be numbers

rate<5

Less than or equal to

<=

Two

Nonzero integer if the first argument is less than or equal to the second argument

Both arguments must be numbers

rate<=5

Logical AND

&&

Two

Nonzero integer if both the arguments are nonzero

Both arguments must be numbers

x == 1 && y >= 5

Logical NOT

!()

One

Zero if the argument is nonzero

All arguments must be numbers

! x ==y

Logical OR

||

Two

Nonzero integer if at least one of the arguments is nonzero

Both arguments must be numbers

x==1 || y>=5

Maximum of the arguments, max() = –infinity

max()

Zero or more

 

All arguments must be numbers

max (1, 3, 2, 4)

Minimum of the arguments, min() = +infinity

min()

Zero or more

 

All arguments must be numbers

min (1, 3, 2, 4)

Negation

One

 

Argument must be a number

–5

Not equal

!=

Two

Nonzero integer if the arguments are not equal

Both arguments must be numbers

rate !=5

Not match

not

One

 

None – expressions with this operator cannot be evaluated

not 192.0.2.1

Product of the arguments

*

Two

 

Both arguments must be numbers

rate*2

Raise the first argument to the power of the second argument

**

Two

 

Both arguments must be numbers

2**16

Range from the first argument to the second argument

..

Two

 

None—expressions with this operator cannot be evaluated

0..49

Remainder of division of the first argument by the second argument

%

Two

 

Both arguments must be integers

5%2

Round off the argument to the closest number

round()

One

Integer closest to the argument

Argument must be numbers

round(986532.654)

Round the argument down

floor()

One

Biggest integer less than or equal to the argument

Argument must be numbers

floor (986532.654)

Round the argument up

ceiling()

One

Smallest integer greater than or equal to the argument

Argument must be numbers

ceiling (986532.654)

Shift the first argument left by the number of bits in the second argument

<<

Two

 

Both arguments must be integers

986532 << 2

Shift the first argument right by the number of bits in the second argument

>>

Two

 

Both arguments must be integers

986532 >>2

Sum of the arguments

+

One or two

 

Both arguments must be numbers

876 + 345

+855

The precedence of the Java operators is the same as the precedence in Java; if you are unsure of the precedence of the operators, you can use parentheses to ensure that the software evaluates expressions in the desired way. For example, the following logical OR expression does not need parentheses.

x==1 || y>=5

You can, however, include parentheses as follows:

(x==1) || (y>=5)

The following list shows the precedence of the operators from lowest precedence to highest precedence:

Related Documentation