SAS provides predefined Liquid filters that you can use to further process the event data it receives. It runs the filters used in an event when it displays the event.
To display the data from your application,
SAS assigns relevant values to the static_data or var_data variables,
and then renders the Liquid template for the relevant event.
For that reason, this section uses the Liquid terminology, instead of the Java terminology, for the description of the filters.
|
This section lists the filters that you may need when you develop applications with Rhino SAS API.
To use the predefined filters, separate the input value and the filter with a |
symbol.
Some filters can have additional parameters.
To specify them, use a colon (:
) followed by a comma-separated list of parameters.
For example, the following template calls the foo
filter with three parameters, static_data[0]
, static_data[1]
, and static_data[2]
:
{{ static_data[0] | foo: static_data[1], static_data[2] }}
You can combine multiple filters. In that case, they are applied from left to right.
Filters for formatting static_data
Data that your application attached to an event using the staticParam()
method is available
to the Liquid templates in the mini-bundle in the static_data
array variable.
Without any filters, SAS renders this variable as an unsigned decimal string, or as an empty string if the value is absent.
To format static_data
in other forms, use the following filters:
Filter name | Description | Parameters |
---|---|---|
|
Treats an integer as a Boolean value and then converts the value to a string. If the integer is For example, the expression |
|
|
Gets a value stored in an enumeration variable defined for an event in the mini-bundle. |
|
|
Formats the input integer as a 32-bit float value. |
|
|
Returns the text description for an integer HTTP status code. For example, the expression |
|
|
Formats the input integer as a signed integer with optional radix (for example, 10 for decimal) parameter. |
|
|
Formats the input integer as an unsigned one with optional radix (for example, 10 for decimal) parameter. |
|
Filters for formatting var_data
Data that your application attaches to an event using the varParam()
method is available
to the Liquid templates in the mini-bundle in the var_data
array variable.
Without any filters, SAS casts the value as UTF-8 encoded text and displays it as such.
If the variable value is not valid UTF-8 encoded text, SAS renders it as Invalid UTF-8 String
.
If the value is absent, SAS renders it as an empty string.
When a Java String is passed to the varParam() method, the corresponding var_data is UTF-8 encoded.
|
Filters for formatting UTF-8 var_data
To format var_data
that is UTF-8 encoded in other forms, use the following filters:
Filter name | Description | Parameters |
---|---|---|
|
Appends an object to another and returns a concatenated string if the first object is present. Otherwise returns an empty string. |
|
|
Appends the specified port number to the input IPv4 address/hostname or IPv6 address. For an IPv6 address, the filter adds brackets. Consider the following example:
If the value of |
|
|
Converts the given JSON object to a well-formatted string. You can use this filter in combination with the
|
|
|
Returns the specified string if the input value is absent. Otherwise returns the input value. |
|
|
Returns the specified string if the input value is blank. Otherwise returns the input value. Consider the following example:
In this example, if the value of the |
|
|
Prepends an object to another and returns a concatenated string if the first object is present. Otherwise returns an empty string. Consider the following example:
If the variable |
|
|
Converts a string into a JSON object. For example, after getting the
You can print the entire JSON structure with this code:
Or print a field with this code:
|
|
Filters for formatting other var_data
To format var_data
that is not UTF-8 encoded, use the following filters.
For example, you may need one of these filters when you pass the contents of a binary encoded message in a byte
array to the varParam()
method.
These filters need to access the raw data form of the input. Don’t use them after other filters because all filters output UTF-8 strings that don’t have a raw data form. |
Filter name | Description | Parameters | ||
---|---|---|---|---|
|
Converts the input, which may include binary data, into a hexadecimal string. |
|
||
|
Interprets the input non UTF-8 data as valid UTF-8 data so that the data can be further processed. Use this filter when SAS needs to process the results of a template render as binary. For example, the variable for the
|
|
||
|
Formats a string as Diameter details. |
|
||
|
Formats a string as a Diameter summary |
|
||
|
Formats a string as SIP details. |
|
||
|
Formats a string as a SIP summary. |
|
||
|
Formats the input string as a directory number. |
|
||
|
Dump a byte string as a hexadecimal string. Returns |
|
||
|
Formats the input data by displaying it as a hex dump, with corresponding printable ASCII characters alongside. Use this filter to display blobs of binary data for which a decoder isn’t available. |
|
||
|
Formats the input string’s byte sequence as an IP address. The filter interprets four bytes as an IPv4 address and 16 bytes as an IPv6 address. |
|