Utils Reference


Example usage of the @date util inside a PEL expression :

pipeline: - log: message: "The current date is: #{@date.now()}"

@calc


Provides utility functions inside a pipeline expression for simple calculations of lists.
You can access the functions declared here in the PEL using <code>@calc</code>
Note: This is a public interface. Methods exposed here can be accessed by external developers in the pipelines!

sum(list)

Does a "nice" sum the values of the given list with high precision.
If an item in the given list is a string, it will be tried
to convert it to a number. If the value is null or cannot be converted it will be excluded from
the summary but no exception is thrown -> be nice.

Returns

bigdecimal - The sum of the given list.

Parameters

Name

Type

Description

Name

Type

Description

ist |

`object`` |

he list of numbers to sum-up.

Example

@calc.sum(list)

avg(list)

Calculates the average on the value of given list with a precision of two decimal points.

Returns

bigdecimal - The calculated AVG.

Parameters

Name

Type

Description

Name

Type

Description

ist |

`object`` |

he list of numbers.

Example

@calc.avg(list)

round(value,scale,mode)

Rounds input to scale number of digits. Multiple rounding strategies can be applied.

Returns

bigdecimal - The rounded value as BigDecimal.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to round. BigDecimal, double, float, integer and long are supported.

cale |

`integer`` |

he scale to round to. Positive value scales in fraction part, negative in integer.

ode |

`string`` |

ne of UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY can be used. For details see https://docs.oracle.com/javase/7/docs/api/java/math/RoundingMode.html

Example

roundUp(value,scale)

Rounds input to scale number of digits up.
See also {@link CalcPelUtil#round(Object, Integer, String)} for more options.

Returns

bigdecimal - The rounded value as BigDecimal.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to round. BigDecimal, double, float, integer and long are supported.

cale |

`integer`` |

he scale to round to. Positive value scales in fraction part, negative in integer.

Example

roundDown(value,scale)

Rounds input to scale number of digits down.
See also {@link CalcPelUtil#round(Object, Integer, String)} for more options.

Returns

bigdecimal - The rounded value as BigDecimal.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to round. BigDecimal, double, float, integer and long are supported.

cale |

`integer`` |

he scale to round to. Positive value scales in fraction part, negative in integer.

Example

@content


Provides utility functions inside a pipeline expression for creation and managing of content objects.
You can access the functions declared here in the PEL using <code>@content</code>

newCollection(uris)

Creates a new content collection and initializes it with given uris.

Returns

contentcollection - A content collection with given uris.

Parameters

Name

Type

Description

Name

Type

Description

ris |

`string`` |

he list of content uris to add to the new collection.

Example

newCollection()

Creates a new, empty content collection at given location.

Returns

contentcollection - The new, empty content collection.

Example

newContent(uri)

Creates a new uri content object and returns it.

Returns

icontent - The new content object.

Parameters

Name

Type

Description

Name

Type

Description

ri |

`string`` |

he uri to be used for the content object

Example

fromBase64(base64String)

Wraps the given base64 string into a content object

Returns

icontent - The content object.

Parameters

Name

Type

Description

Name

Type

Description

ase64String |

`string`` |

he base64 string.

Example

fromBase64(base64String,name)

Wraps the given base64 string into a content object

Returns

icontent - The content object.

Parameters

Name

Type

Description

Name

Type

Description

ase64String |

`string`` |

he base64 string.

ame |

`string`` |

he name of the content object (= file name)

Example

fromBase64(base64String,name,contentType)

Wraps the given base64 string into a content object

Returns

icontent - The content object.

Parameters

Name

Type

Description

Name

Type

Description

ase64String |

`string`` |

he base64 string.

ame |

`string`` |

he name of the content object (= file name)

ontentType |

`string`` |

he content type of the base64 encoded string (when converted back).

Example

from(object,contentType,contentEncoding,name)

Tries to convert the given object to a content object which can be used
to persist the data.

Returns

icontent - The content object.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

ontentType |

`string`` |

he content type to be set on the content object.

ontentEncoding |

`string`` |

he encoding to be set on the content object.

ame |

`string`` |

he name to be set on the content object.

Example

from(object,name)

Tries to convert the given object to a content object which can be used
to persist the data.

Returns

icontent - The content object.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

ame |

`string`` |

he name to be set on the content object.

Example

from(object)

Tries to convert the given object to a content object which can be used
to persist the data.

Returns

icontent - The content object.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

Example

@convert


Provides utility functions inside a pipeline expression for simple conversion and encoding tasks.
You can access the functions declared here in the PEL using <code>@convert</code>

toBase64(value)

Encodes the given value to base64. If value is not a text, it will be converted to a text before conversion.

Returns

string - The encoded string.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to encode.

Example

fromBase64(base64String)

Decodes the given base64 encoded string.

Returns

string - The decoded string.

Parameters

Name

Type

Description

Name

Type

Description

ase64String |

`string`` |

he base64 encoded string.

Example

fromBase64ToBytes(base64String)

Decodes the given base64 encoded string.

Returns

byte[] - The decoded string as byte array.

Parameters

Name

Type

Description

Name

Type

Description

ase64String |

`string`` |

he base64 encoded string.

Example

toJson(object)

Converts a given object structure to JSON.

Returns

jsonnode - The resulting JSON.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

Example

toXMLString(object)

Converts a given object to an XML string.

Returns

string - The resulting XML string.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

Example

toDOM(object)

Converts a given object to an XML DOM representation.

Returns

document - The resulting DOM tree.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

Example

toMap(object)

Converts the given object to a map structure.

Returns

map - The converted map structure or null in case input was null.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert to a map structure.

Example

toMapOrList(o)

Converts the given object to a map or list structure depending on which is more appropriate.

Returns

object - The converted map or list structure or null in case input was null.

Parameters

Name

Type

Description

Name

Type

Description

|

`object`` |

he object to convert to a map or list structure.

Example

lazy(uri)

Converts all supported uri variants to LazyUriMap

Returns

object - The lazy uri map.

Parameters

Name

Type

Description

Name

Type

Description

ri |

`string`` |

he uri to load from.

Example

toLong(value)

Converts the given value to a long value.
If input value is the boolean true or false, 1 or 0 as long is returned.
If input is the string "true" or "false, 1 or 0 as long is returned.
If input is empty string "", 0 is returned.

Returns

long - The converted long value or null in case the input was null.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value object to convert to long.

Example

toInteger(value)

Converts the given value to a long value.
If input value is the boolean true or false, 1 or 0 as int is returned.
If input is the string "true" or "false, 1 or 0 as int is returned.
If input is empty string "", 0 is returned.

Returns

integer - The converted integer value or null in case the input was null.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value object to convert to integer.

Example

toBoolean(value)

Converts the given value to a boolean value.
If input is the string "true" or "false, true or false as boolean is returned.
If input is empty string "", false is returned.
If input is null, false is returned.
Any numeric value > 0, true is returned.
Any numeric value <= 0, false is returned.

Returns

boolean - The converted boolean value.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value object to convert to boolean.

Example

toDecimal(value)

Converts the given value into a big decimal with given precision.

Returns

double - The decimal number as double.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to convert.

Example

toDecimal(value,decimalSymbol)

Converts the given value to a decimal number.

Returns

bigdecimal - The value as decimal number ready for calculations.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to convert to decimal.

ecimalSymbol |

`string`` |

he decimal symbol to be used. Can be a comma , a dot . or a locale tag like de, en, fr for example. If null or empty, the locale tag of the currently logged-in user is used. If this is null, locale tag de is used as default.

Example

toDecimal(value,pattern,decimalSymbol)

Converts the given value to a decimal number by applying the given pattern and locale.

Returns

bigdecimal - The value as decimal number ready for calculations.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to convert to decimal.

attern |

`string`` |

he decimal pattern to apply. For example: #.###

ecimalSymbol |

`string`` |

he decimal symbol to be used. Can be a comma , a dot . or a locale tag like de, en, fr for example. If null or empty, the locale tag of the currently logged-in user is used. If this is null, locale tag de is used as default.

Example

toDecimalString(value,pattern,decimalSymbol)

Formats a given number to a decimal string using the given decimal pattern and
locale tag like de, en, fr aso.

Returns

string - The decimal string.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he decimal number to format to a string.

attern |

`string`` |

he decimal pattern like #.## for example.

ecimalSymbol |

`string`` |

he decimal symbol to be used. Can be a comma , a dot . or a locale tag like de, en, fr for example. If null or empty, the locale tag of the currently logged-in user is used. If this is null, locale tag de is used as default.

Example

toDecimalString(value,decimalSymbol)

Formats a given number to a decimal string using the given locale tag like de, en, fr aso.

Returns

string - The decimal string.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he decimal number to format to a string.

ecimalSymbol |

`string`` |

he decimal symbol to be used. Can be a comma , a dot . or a locale tag like de, en, fr for example. If null or empty, the locale tag of the currently logged-in user is used. If this is null, locale tag de is used as default.

Example

toByteArray(object)

Converts the given object to a byte array.

Returns

byte[] - The byte array.

Parameters

Name

Type

Description

Name

Type

Description

bject |

`object`` |

he object to convert.

Example

@data


Provides utility functions inside a pipeline expression for simple CRUD and transformation data operations.
You can access the functions declared here in the PEL using <code>@data</code>

set(data,path,value)

Sets the given value on the given data object at the given element path where every item is separated by a dot.
If an item at the given path doesnt exist, it will be created automatically (is supported by given object).
For example to create a new entry person.name inside a given map, you could use:
<code>set(someMap, "person.name", "Some Name")</code>. This will create the nested map person with an entry of
type name in it.

Returns

object - The data object with value set at the specific path.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data object.

ath |

`string`` |

he path inside the data object to set the value.

alue |

`object`` |

he value to set.

Example

put(map,key,value)

Expects the given data to be map-like structure and puts the given value under given key to it.
Overwrites any existing entry under this key.

Returns

object - The map like data structure with the new entry added.

Parameters

Name

Type

Description

Name

Type

Description

ap |

`object`` |

he map-like data structure.

ey |

`object`` |

he key to add the value under.

alue |

`object`` |

he value to add.

Example

select(input,selections)

Applies the given selection string on the given input object in order to extract
data from the input object. If there is more than one selection string, puts the
result of each string into a new map entry whereas the key is the selection string
or the name from the "AS NAME" suffix (note the upper case AS). Examples of selection strings:
<ul>
<li>'person.firstName' = Extracts the firstName from the input object and returns the result as a
entry in the mapping using the key 'person.firstName'. If it is the only selection string, returns the
value directly.</li>
<li>'person.firstName AS name' = Extracts the firstName from the input object and returns the result as a
entry in the mapping using the key 'name'</li>
<li>'person.hobbies.size()' = Extracts the number of hobbies from the input object and returns the result as a
entry in the mapping using the key 'person.hobbies.size()'. If it is the only selection string, returns the
value directly.</li>
<li>'person.hobbies.size() AS numOfHobbies' = Extracts the number of hobbies from the input object and returns
the result as an entry in the mapping using the key 'numOfHobbies'</li>
</ul>

Returns

object - The extracted data.

Parameters

Name

Type

Description

Name

Type

Description

nput |

`object`` |

he input to apply the selection strings on. May not be null.

elections |

`string`` |

ne or more selection strings. If null or empty, returns an empty map.

Example

integerList(startInt,endInt)

Creates a new list and fills it with integers from startIndex up to endIndex.
For example a call of createListWithIntegers(2, 5) would return a list with these entries:
[2,3,4,5].

Returns

list<integer> - A list of given size filled-up with digits.

Parameters

Name

Type

Description

Name

Type

Description

tartInt |

`int`` |

he start index to fill the list.

ndInt |

`int`` |

he end index to fill the list up to.

Example

size(value)

Calculates the size of the given value regardless of the type it is.

Returns

long - The size of the value. Returns a size of 0 in case the input value is null or cannot be counted.

Parameters

Name

Type

Description

Name

Type

Description

alue |

`object`` |

he value to count for size.

Example

isEmpty(data)

Checks if given data structure is null or empty.
For example:
<ul>
<li>If it is a list, returns true in case the list contains no entry or is null.</li>
<li>If it is a map, returns true in case the map contains no entry or is null.</li>
<li>If it is a node, returns true in case the node contains no entry or is null.</li>
<li>If it is a string, returns true in case the string contains no chars or is null.</li>
</ul>

Returns

boolean - true in case the given list is null or empty.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data structure to check.

Example

has(data,attribute)

Checks whether given data object has an attribute, member or getter with given name.
Also supports property path syntax for recursive search on given data object.
Whereas each property name must be separated by a dot.
For example: person.firstName

Returns

boolean - true in case the data object has given attribute.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data object to scan for attribute.

ttribute |

`string`` |

he attribute name to search for.

Example

get(data,attribute)

Returns the value of the given data attribute or null in case it doesn't exist.
This way an additional attribute non-existent check can be avoided.

Returns

object - The value from given data with given attribute name.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data to read the value from.

ttribute |

`string`` |

he attribute name to read from the data.

Example

emptyObject()

Returns a new empty object (map).

Returns

map - A new, empty object (map).

Example

emptyList()

Returns a new empty list.

Returns

list - A new, empty list.

Example

keys(data)

Returns the keys of the given object at root level. Which could be a JSON object for example.
If the object doesn't have a key, returns empty list. Never null.

Returns

list<string> - The list of key of this object.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

key value structure.

Example

type(data)

Returns the type of the given data object. Can be one of:
<ul>
<li>OBJECT = A (JSON) object.</li>
<li>ARRAY = A (JSON) array.</li>
<li>STRING = A (JSON) string.</li>
<li>NUMBER = A (JSON) number.</li>
<li>BOOLEAN = A (JSON) boolean.</li>
<li>NULL = A (JSON) null.</li>
</ul>

Returns

string - The type of the data. Never null.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data to check the type for.

Example

isType(data,type)

Checks whether the given data is of given type. Valid type keys are:
<ul>
<li>OBJECT = A (JSON) object.</li>
<li>ARRAY = A (JSON) array.</li>
<li>STRING = A (JSON) string.</li>
<li>NUMBER = A (JSON) number.</li>
<li>BOOLEAN = A (JSON) boolean.</li>
<li>NULL = A (JSON) null.</li>
</ul>

Returns

boolean - True in case the given data is of given type.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data to check for the type.

ype |

`string`` |

he type string to check for.

Example

isArray(data)

Checks if given data is an array.

Returns

boolean - true, if data is an array.

Parameters

Name

Type

Description

Name

Type

Description

ata |

`object`` |

he data to check for.

Example

isBoolean(data)

Checks if given data is a boolean.

Returns

boolean - true, if data is a boolean.

Parameters

Name

Type

Description