Expression Language Functions

Top  Previous  Next

Expression language functions perform some processing of their input parameters and return some value. Several functions (such as random) do not have input parameters at all.

note_further-wt

It is important to keep the distinction between expression language functions and context functions that may appear inside references.

Number Processing Functions

Function

Description

Result Type

abs(Float value)

Returns the absolute value of a value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned.

If argument type is Integer or Long, return value is Long.

Float

acos(Float value)

Returns the arc cosine of an angle, in the range of 0.0 through pi.

Float

asin(Float value)

Returns the arc sine of an angle, in the range of -pi/2 through pi/2.

Float

atan(Float value)

Returns the arc tangent of an angle, in the range of -pi/2 through pi/2.

Float

cbrt(Float value)

Returns the cube root of a value.

Float

ceil(Float value)

Returns the smallest (closest to negative infinity) value that is greater than or equal to the argument and is equal to a mathematical integer.

Float

cos(Float value)

Returns the trigonometric cosine of an angle. Angle is measured in radians.

Float

cosh(Float value)

Returns the hyperbolic cosine of a value.

Float

e()

Returns the base of the natural logarithms.

Float

eq(Long first, Long second)

Returns true if first argument is equal to the second argument (same as == operator).

Boolean

exp(Float value)

Returns Euler's number e raised to the power of a value.

Float

floor(Float value)

Returns the largest (closest to positive infinity) value that is less than or equal to the argument and is equal to a mathematical integer.

Float

ge(Long first, Long second)

Returns true if first argument is greater or equal than second argument (same as >= operator).

Boolean

gt(Long first, Long second)

Returns true if first argument is greater than second argument (same as > operator).

Boolean

le(Long first, Long second)

Returns true if first argument is less or equal than second argument (same as <= operator).

Boolean

log(Float value)

Returns the natural logarithm (base e) of a value.

Float

log10(Float value)

Returns the base 10 logarithm of a value.

Float

lt(Long first, Long second)

Returns true if first argument is less than second argument (same as < operator).

Boolean

min(Float first, Float second)

Returns the smaller of two values.

If argument types are Integer or Long, return value is Long.

Float

max(Float first, Float second)

Returns the greater of two values.

If argument types are Integer or Long, return value is Long.

Float

ne(Long first, Long second)

Returns true if first argument is not equal to the second argument (same as != operator).

Boolean

pi()

Returns the ratio of the circumference of a circle to its diameter.

Float

pow(Float base, Float power)

Returns the value of the first argument raised to the power of the second argument.

Float

random()

Returns a value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range.

Float

round(Float value)

Returns the closest integer to the argument.

Long

signum(Float value)

Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.

If argument type is Integer or Long, return value is Long.

Float

sin(Float value)

Returns the trigonometric sine of an angle. Angle is measured in radians.

Float

sinh(Float value)

Returns the hyperbolic sine of a value.

Float

sqrt(Float value)

Returns the correctly rounded positive square root of a value.

Float

tan(Float value)

Returns the trigonometric tangent of an angle. Angle is measured in radians.

Float

tanh(Float value)

Returns the hyperbolic tangent of a value.

Float

String Processing Functions

Function

Description

Result Type

contains(String string, String substring)

Returns true if and only if string contains the specified substring.

Boolean

endsWith(String string, String suffix)

Returns true if string ends with the specified suffix. Note that the result will be true if the suffix is the empty string or is equal to the string argument.

Boolean

index(String string, String substring)

Returns the zero-based index within string of the first occurrence of the specified substring or -1 if not found.

Integer

index(String string, String substring, Integer fromIndex)

Returns the zero-based index within string of the first occurrence of the specified substring, starting at the specified fromIndex. If substring is not found, -1 is returned.

Integer

lastIndex(String string, String substring)

Returns the zero-based index within string of the rightmost occurrence of the specified substring or -1 if not found.

Integer

lastIndex(String string, String substring, Integer fromIndex)

Returns the zero-based index within string of the rightmost occurrence of the specified substring, searching backward starting at the specified fromIndex. If substring is not found, -1 is returned.

Integer

length(String string)

Returns the length of the string.

Integer

replace(String string, String target, String replacement)

Replaces each substring of the string that matches the target substring with the specified replacement string. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".

String

startsWith(String string, String prefix)

Returns true if string starts with the specified prefix. Note also that true will be returned if the prefix is an empty string or is equal to the string.

Boolean

substring(String string, Integer beginIndex)

Returns a new string that is a substring of the string. The substring begins with the character at the specified beginIndex and extends to the end of the string.

Examples:

substring("unhappy", 2) returns "happy"

substring("Harbison", 3) returns "bison"

substring("emptiness", 9) returns "" (an empty string)

String

substring(String string, Integer beginIndex, Integer endIndex)

Returns a new string that is a substring of the string. The substring begins at the specified beginIndex (inclusively) and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex - beginIndex.

Examples:

substring("hamburger", 4, 8) returns "urge"

substring("smiles", 1, 5) returns "mile"

String

lower(String string)

Converts all of the characters in the string to lower case.

String

upper(String string)

Converts all of the characters in the string to upper case.

String

trim(String string)

Returns a copy of the string, with leading and trailing whitespace omitted.

String

Date/Time Processing Functions

Function

Description

Result Type

now()

Returns current date/time.

Date

year(Date date)

Returns year of the specified timestamp.

Integer

month(Date date)

Returns month of the specified timestamp (0 for January).

Integer

day(Date date)

Returns day of the specified timestamp.

Integer

hour(Date date)

Returns hour of the specified timestamp.

Integer

minute(Date date)

Returns minute of the specified timestamp.

Integer

second(Date date)

Returns second of the specified timestamp.

Integer

millisecond(Date date)

Returns millisecond of the specified timestamp.

Integer

dayOfYeah(Date date)

Returns day of year of the specified timestamp.

Integer

dayOfWeek(Date date)

Returns day of week of the specified timestamp (0 for Sunday).

Integer

time(Date date)

Returns number of milliseconds since Epoch for the specified timestamp.

Long

date(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second)

Constructs date by the specified year, month, day, hour, minute, and second values. Note, that month is zero-based, i.e. value for January is 0.

Date

dateDiff(Date first, Date second, String unit)

Calculates time passed since first date till second date, measured in named unit(s).

Unit names:

millisecond or ms for Milliseconds
second, sec or s for Seconds
minute, min or m for Minutes
hour, hr or h for Hours
day or d for Days
week or w for Weeks
month for Months (Note, that month is zero-based, i.e. value for January is 0.)
year or y for Years

Long

dateAdd(Date date, Integer count, String unit)

Adds count periods of time specified by named unit(s) to the date, and returns the result. See unit names above.

Date

Color Processing Functions

Function

Description

Result Type

color(Integer red, Integer green, Integer blue)

Constructs a color by three RGB values. Each component may must be in 0..255 range.

Color

red(Color color)

Returns red component of a color (0...255).

Integer

green(Color color)

Returns green component of a color (0...255).

Integer

blue(Color color)

Returns blue component of a color (0...255).

Integer

brighter(Color color)

Applies an arbitrary scale factor to each of the three RGB components of color argument to create a brighter version of this color.

Color

darker(Color color)

Applies an arbitrary scale factor to each of the three RGB components of color argument to create a darker version of this color.

Color

Data Table Processing Functions

Function

Description

Result Type

addColumns(DataTable table, String format1, String expression1, String format2, String description2, ...)

Adds one or more columns to the table. Format of the first added column is specified by format1 argument, its value is defined by expression1, etc. Format is encoded into string as specified by format encoding section (visible separators are used). Value for this field is calculated by evaluating the expression that may contain references to the other cells of this table. If row is not specified in the reference, it defaults to the current row (i.e. one for that new field's value is calculated).

Example: addColumns({.:hrStorageTable}, "<usage><S>", "{hrStorageUsed} * 100 / {hrStorageSize} + ' %') returns a copy of original table with one new column named usage of type String. Values for this column are calculated using {hrStorageUsed} * 100 / {hrStorageSize} + ' %' expression that references two other columns of the same table.

DataTable

aggregate(Object source, String expression, Object initialValue)

Calculates some "aggregate value" for a Data Table (if source argument is a Data Table) or a number of contexts (if source argument is a String representing context mask). If the first argument is a Data Table, goes through every record of it and calculates an expression for it, making source Data Table a default table, and current row a default row. If source is a context mask, expression is calculated for every context which matches the mask, making it a default context.

The expression usually operates over two values: the value of the previous calculation that may be referred using {env/previous} reference (see Environment References) and value(s) from the current context/record referred by standard references. During the first calculation, {env/previous} returns the value of initialValue argument.

Example 1: aggregate("users.*.devices.*", "{env/previous} + ({.:status$connectionStatus} == 1 ? 1 : 0)", 0)

This expression will calculate the number of online ({.:status$connectionStatus} == 1) devices in the system by going over all device contexts (users.*.devices.* mask) and adding 1 to the "aggregate" value if the device is online. The initial value is zero.

Example 2: aggregate({}, '{env/previous} || ({prtCoverStatus} == "open")', false)

In this case, the result is calculated by going over the records of the default Data Table (returned by {} reference). The initial "aggregate" value is Boolean value false. The final result will be true if prtCoverStatus field is equal to open in at least one record, and false otherwise.

Example 3: aggregate({}, max({env/previous}, {field}), 0)

The above expression will return maximum value found in the field column.

Object

cell(DataTable table, String field [, Integer row [, Boolean description]] )

Returns value contained in the cell of Data Table passed in the first argument. Cell is specified by field and row parameters. If row is not specified, value of field in the first row is returned. If field is a number, it is considered to be field index instead of its name.

If description parameter is specified and is true, the function returns description of cell value instead of the value itself (only if field format specifies selection values).

Example: cell({users:list()}, "firstname", 5) will return firstname field from 6th row (index = 5) of table containing a list of user accounts (obtained by calling list() context function from Users context).

Object

convert(DataTable table, String format)

Converts table to the format specified by format argument. Format is encoded into string as specified by format encoding section (visible separators are used). After a new empty table of the specified format is created, the function does its best to copy all data from table to a new table using Data Table smart copy operation.

Example: convert({}, '<<f1><S><A=123>> <<f2><B>>') expression will create a table with String field f1 and Boolean field f2 and copy all data from default table to the newly created table. If default table has field f1 of type Integer, field type will be converted, but all data will be preserved.

DataTable

describe(DataTable table, String field1, String description1, String field2, String description2, ...)

Changes description of field named field1 to description1, etc. Returns resulting table.

Example: describe({.:ifTable}, "ifDescr", "Name", "ifAdminStatus", "Status", "ifType", "Type", "ifSpeed", "Speed") returns a copy of original table where descriptions of ifDescr, ifAdminStatus, ifType, and ifSpeed fields are changed to Name, Status, Type, and Speed respectively.

DataTable

description(DataTable table)

Returns description of the table, i.e. result of its Naming Expression evaluation.

String

print(DataTable table, String expression, String separator)

Calculates expression for every record of the table and appends output to a resulting string separating results by separator.

Example: print({users:list()}, "{firstname}", ", ") will return of user's first names, e.g. Amanda, Michelle, John, Donald, Paul

String

select(DataTable table, String fieldToSelect, String fieldToCheck, Object value)

Scans table row-by-row and checks if value of fieldToCheck is equal to value. If true, returns value of fieldToSelect from current record. If no matching records found in the table, this function returns NULL.

Example: select({users:list()}, "firstname", "username", "john") will return first name of user with username john, selected from the user stats table (see example above).

Object

subtable(DataTable table, String field1, String field2, ...)

Accepts a table as an argument and returns another table that contains only fields whose names are specified by fields argument. Format and content arn preserved in the returned subtable.

Example: subtable({users:list()}, "firstname", "lastname") will return a table with two columns containing first and last names of all AggreGate Server users.

DataTable

TYPE CONVERSION Functions

Function

Description

Result Type

string(Object value)

Converts argument to a String.

String

boolean(Object value)

Converts argument to a Boolean.

Boolean

integer(Object value)

Converts argument to an Integer number.

Integer

long(Object value)

Converts argument to a Long number.

Long

float(Object value)

Converts argument to a Float number.

Float

Context-Related Functions

Function

Description

Result Type

hasVariable(String context, String variable)

Returns true if context with path specified by context argument has variable specified by variable argument.

Boolean

hasFunction(String context, String function)

Returns true if context with path specified by context argument has function specified by function argument.

Boolean

hasEvent(String context, String event)

Returns true if context with path specified by context argument has variable specified by event argument.

Boolean

OTHER Functions

Function

Description

Result Type

format(Object value, String pattern)

Formats Number or Date value to a String. Number formatting patterns are described here. Date formatting patterns are here.

String

evaluate(String expression)

Evaluates its string argument as an AggreGate expression and returns the result.

Object

sleep(Integer milliseconds)

Causes the thread processing this expression to pause execution for the specified number of milliseconds.

Null