Skip to content

Extendable Query Language

anymaker edited this page Mar 29, 2021 · 5 revisions

Formula specification

See test Demo.java, where demonstrated possibilities.

Numeric literal

  125    125.2

String literal

  'string'

Operations

  *     miltiple                              2 * 2           4
  /     divide                                4 / 2           2
  %     remainder of integer division         3 % 2           1
  +     plus                                  1 + 2           3
  -     minus                                 1 - 2           -1
  =     equal                                 1 = 2           false
  !=    not equal                             1 != 2          true
  >     great                                 2 > 1           true
  >=    great or equal                        2 >= 2          true
  <     less                                  1 < 2           true
  <=    less or equal                         2 <= 2          true
  ,     add to list                           1, 2            [1,2]
  in    is in list                            2 in (1,2,3)    true

Pointer to data

  .stepOne.stepTwo

If exists map where present key 'stepOne', then in first step while you get value for this key. If on previous step returned map which contain key 'stepTwo' - you getting value for key 'stepTwo'.

Example 1

data: {stepOne: {stepTwo: 2}}

formula: .stepOne.stepTwo

You will get 2

Example 2

data: [{stepOne: {stepTwo: 2}, {stepOne: {stepTwo: 3}]

formula: .stepOne.stepTwo

You will get array [2, 3]

Filtering data

  .stepOne(.stepTwo = 2)

If exists collection of the map and map contain key 'stepOne', and value of 'stepOne' is a map with existing key 'stepTwo', you will get only the map-object, witch contain value of 'stepTwo' == 2.

Example

data: [ { stepOne: { stepTwo: 2 }, { stepOne: { stepTwo: 3 } ]

formula: .stepOne(.stepTwo = 2)

You will get: {stepOne: {stepTwo: 2}}

In a filter you can use any operations and any functions.

Functions

Functions can contain parameters or be without parameters. If function has no parameters then you do not need specify brackets.

With parameters

 count(.num)

Without parameters

 isFirstRow

null, true, false - this is a functions without parameters. Different data source can understand different functions. You can specify own functions - see below.

Function name is not case sensitive. You can write Null or nUll or NULL - it's all the same function.