51.4.2.3 51.4.2.2 51.4.2.1 51.4.2.0 51.4.1.1 51.4.1.0 51.3.0.0 51.2.0.17 51.2.0.12 51.2.0.11 51.2.0.5 51.2.0.2
51.4.2.3 51.4.2.2 51.4.2.1 51.4.2.0 51.4.1.1 51.4.1.0 51.3.0.0 51.2.0.17 51.2.0.12 51.2.0.11 51.2.0.5 51.2.0.2

SFormat

Active SFormat is a extended version of Niagara BFormat (a super BFormat). It provides additional features to navigate through components and relations, read tags, modify text (escape, substring, etc) and so on.

A SFormat is defined by a chain of characters between curly brackets {…} and is a succession of functions used to build the result. Unlike the BFormat wich can only returns a String, the SFormat result can be a component or any object.

{parent.relations('out','b:isIn').item(1).%displayName%} -> take the parent, then follow its outbound relations b:isIn, then take the second element (because there might be several relations) and then apply a BFormat to get the displayName

Functions in a SFormat can take parameters between parenthesis and separated by a coma. It can take one of the following parameters depending on the function:

    • String: 'param'

    • Number: 3 or 6.4

    • Boolean: true or false

SFormat is used in Active components such as InfoSource, HistoryDisplayName management and is mainly used in Strategies.

{parent.inRel('b:isIn')}

Classic BFormat can be defined between %...% (as usual). It can be introduced after the definition of a component by SFormat functions or directly at the root as a classic BFormat.

{parent.inRel('b:isIn').%displayName%}

If you want to avoid interpretation of SFormat, you can use [...], so the format will not be resolved.

station:|slot:|bql:select slotPathOrd, displayName, [btibCore:BqlLib.sFormat('{origin.inRel(b:strSourceOf).parent.%slotPathOrd%}')] from btibStructure:Node where b:floor = '{origin.%displayName%}'

will result in:

station:|slot:|bql:select slotPathOrd, displayName, btibCore:BqlLib.sFormat('{origin.inRel(b:strSourceOf).parent.%slotPathOrd%}') from btibStructure:Node where b:floor = 'Floor 1'

Here is the list of the functions currently implemented by the SFormat:

Name

Description

Base Type

Parameters

Return Type

parent

Get the parent of a component.

Component

-

Component

children

Get the children of a component.

Component

-

Array

slot

Get a slot of a component.

Component

  • Slot name

Object

child

Deprecated. This function is now called 'slot'.

Component

  • Child name

Object

length

Get the size of an array or of a String.

Array

-

Number

item

Get the item of an array at a given index. Index starts at 0.

Array

  • Index of the item

Object

first

Get the first item of an array.

Array

-

Object

last

Get the last item of an array.

Array

-

Object

removeFirst

Remove the first item of the array return the array.

Array

-

Array

removeLast

Remove the last item of the array return the array.

Array

-

Array

removeDuplicates

Remove the duplicates from an array.

Array

-

Array

filter

Filter the values of an array. Value is valid if equals to the given String, boolean or double.

Array

  • Value of the value to filter

Array

display

Convert an array into a String using a format. Format is applied to each value of the array. Use [] to protect SFormat from resolve. Use \n for line break.

Array

  • Format to apply

String

ord

Execute a query: slotPathOrd, bql or neql. Base: absolute or relative.

Component

  • Query

Array

escape

Escape a String.

String

-

String

unescape

Unescape a String.

String

-

String

toFriendly

Convert a String to friendly case.

String

-

String

fromFriendly

Convert a String from friendly case.

String

-

String

fileName

Replace special chars (including accents) by _

String

-

String

safeName

Stripe accents and replace special chars by _

String

-

String

substring

Reduce a String between two indexes.

String

  • Start index

  • End index

String

substringFromEnd

Remove x characters from a String, starting at the end.

String

  • Number of chars to remove

String

indexOf

Return the index of an input String.

String

  • String to match

Number

replace

Replace an input String in the base.

String

  • String to replace

  • String of replacement

String

prefix

Will return the prefix followed by the base if the base is not null or empty.

String

  • Prefix

String

suffix

Will return the base followed by the suffix if the base is not null or empty.

String

  • Suffix

String

split

Split a String depending on a sequence of chars.

String

  • String to split at

Array

splitRegex

Split a String depending on a regex.

String

  • Regex to split at

Array

orEmpty

Will return the base if the base is not null or empty.

String

-

Boolean

toDynamicEnum

Convert an array into a value to a dynamic enum.

Array

-

DynamicEnum

toDynamicEnums

Convert an array of x elements into an array of x enums with only one value.

Array

-

DynamicEnums

toString

Convert the base in a String.

Object

-

String

toInt

Convert the base in an integer.

Object

-

Number

toDouble

Convert the base in a double.

Object

-

Number

toOrd

Convert the base in an ord.

Object

-

Ord

toBrush

Convert the base in a brush.

Object

-

Brush

toTag

Get the tag of the value of an enum.

Object

-

String

toDisplayTag

Get the display tag of the value of an enum.

Object

-

String

toSimple

Convert the base in a Simple.

Object

  • Type of the Simple (ex: baja:Color)

Simple

add

Add a number to another.

Number

  • Number to add to base

Number

subtract

Subtract a number to another.

Number

  • Number to subtract from base

Number

multiply

Multiply a number to another.

Number

  • Number to multiply base

Number

divide

Divide a number to another.

Number

  • Number to divide vase

Number

pxView

Get the ord of the file of a pxView.

Component

  • Name of the px view

  • OR Index of the px view

  • OR nothing (will take first view)

Ord

isType

Return whether a component is from the given type or not.

Component

  • Type (ex: baja:Folder)

Boolean

checkType

Return the base if it's from the given type.

Component

  • Type (ex: control:ControlPoint)

Boolean

makeType

Create a new instance of a type.

Component

  • Type (ex: control:BooleanWritable)

Object

exists

Return whether an object/slot exists, i.e. is not null.

Object

-

Boolean

isNull

Return whether an object is null. Also see isInvalid() function.

Object

-

Boolean

isEmpty

Return whether an array is empty.

Array

-

Boolean

isInvalid

Return whether an object is null or a String is equals to "null", is empty or contains "err:".

String

-

Boolean

property

Get a property of a component identified by its name. Property includes name, value, flags and facets.

Component

  • Name of the property

Object

properties

Get all the properties of a component. Property includes name, value, flags and facets.

Component

-

Array

frozenProperties

Get all the frozen properties of a component. Property includes name, value, flags and facets.

Component

-

Array

dynamicProperties

Get all the dynamic properties of a component. Property includes name, value, flags and facets.

Component

-

Array

tagProperties

Get all the properties with a metadata flag of a component. Property includes name, value, flags and facets.

Component

-

Array

number

Extract a number at the end of a String.

String

  • Max characters count (ex: 2 if max number is 99)

String

addFacets

Concatenates facets.

BFacets

  • Facets to add

BFacets

removeFacets

Remove a key from facets.

BFacets

  • Key to remove

BFacets

format

Resolve a BFormat or BSFormat slot on the last base.

Component

  • Format to resolve

Object

method

Call a method on the base with the given parameters.

Object

  • Method name

  • Parameters if needed

Object

methodWithCx

Call a method on the base with the given parameters and the context.

Object

  • Method name

  • Parameters if needed

Object

json

Extract a value from a json. See JsonFormat documentation: JSON Key Selector

Json

See JsonFormat documentation

Json / Primitive

equals

Return whether a member is equal to an other.

String / Double / Boolean

  • String

  • OR Double

  • OR Boolean

Boolean

like

Return whether a String is like an other.

String

  • String to compare to. Can start and/or end by wildcard *

Boolean

lessThan

Return whether a number is less than an other.

Number

  • Number to compare to

Boolean

greaterThan

Return whether a number is greater than an other.

Number

  • Number to compare to

Boolean

and

Return true if both conditions are valid.

Boolean

  • Boolean to compare with base

Boolean

or

Return true if at least one of the conditions is valid.

Boolean

  • Boolean to compare with base

Boolean

not

Return true if the base is false and false if the base is true.

Boolean

-

Boolean

node

Get the first node of the results. See nodes() method.

Node / InfoSource

  • Level of the node

  • OR nothing

Node

nodes

For infoSources: get the nodes from which the component is source of on the given aspect.

For nodes: get the ascendants node of a given level.

Node / InfoSource

  • Level of the node

  • OR nothing

Node

infoSource

Get the infoSource of a source.

Component

-

InfoSource

tag

Get the value of a tag.

Component

  • Name of the tag

Object

inRel

Get the endpoint of the first inbound relation with the given id.

Component

  • Id of the inbound relation

Component

outRel

Get the endpoint of the first outbound relation with the given id.

Component

  • Id of the outbound relation

Component

rel

Get the endpoint of the first relation with the given id in the given direction.

Component

  • Direction: in, out or both

  • Id of the relation

Component

relations

Get the endpoints of all the relations with the given id in the given direction.

Component

  • Direction: in, out or both

  • Id of the relation

Array

inLink

Get the endpoint of the first inbound link on the given slot.

Component

  • Target slot name

Component

outLink

Get the endpoint of the first outbound link on the given slot.

Component

  • Source slot name

Component

link

Get the endpoint of the first link on the given slot in the given direction.

Component

  • Direction: in, out or both

  • Slot name

Component

links

Get the endpoints of all the links on the given slot in the given direction.

Component

  • Direction: in, out or both

  • Slot name

Array

category

Get a category created with a CategoryBlock.

Component

-

Category

hasCategory

Check if a component has the given category.

Component

  • Category

Boolean

hasExactCategory

Check if a component has only the given category.

Component

  • Category

Boolean

hasCategories

Check if a component has the given categories.

Component

  • Array of categories

Boolean

hasExactCategories

Check if a component has the only given categories.

Component

  • Array of categories

Boolean

widget

Get a widget identified by an id.

Base

  • Id of the widget (from Id Binding)

Widget

column

Get a column of a table. Column can be identified by name or index. Index is starting at 0. Index 0 is often timestamp, 1 is often status.

Table

  • Index

  • OR name

Column

columns

Get all the columns of a table

Table

-

Array