String aFunctions

BYTE_STRING_DECODE

BYTE_STRING_DECODE(Object byteArrayString, String charsetName)

Decode a Java primitive byte array Object or ‘byte array String’ into the human readable form. Useful when fetching values from AS400 systems.

Byte array String: ‘Byte array String’ will have a pattern ^^@>{Bytes}[byte[0], byte[1], ...]^^@>{Bytes} ‘Comments’. Trailing separator and comment part is optional, and they are only to improve human readability.

Arguments:
  • byteArrayString (java.lang.Object) – byteArrayString.
  • charsetName (java.lang.String) – Character set name that should be used while decoding bytes into characters.
Return-type :

java.lang.String

Returns:

The human readable decoded String value for the given ‘byteArrayString’.

Example:

=BYTE_STRING_DECODE("^^@>{Bytes}[-120, -123, -109, -109, -106]", "IBM037")
Output: "hello"

Note

AdapLink Data Exchange when receiving Java primitive byte array objects from systems like AS400, then the byte array is automatically converted to the corresponding byte array String and stored for further processing.

BYTE_STRING_ENCODE

BYTE_STRING_ENCODE(String value, String charsetName, Integer fixed_length)

Encode a human readable String to ‘byte array String’. Useful when writing values to AS400 systems.

Byte array String: ‘Byte array String’ will have a pattern ^^@>{Bytes}[byte[0], byte[1], ...]^^@>{Bytes} ‘Comments’. Trailing separator and comment part is optional, and they are only to improve human readability.

Arguments:
  • value (java.lang.String) – Input string.
  • charsetName (java.lang.String) – charsetName that should be used while encoding String value to byte array String.
  • fixed_length (java.lang.Integer) – fixed_length.
Return-type :

java.lang.String

Returns:

The ‘encoded byte array String’ for the given value.

Example:

=BYTE_STRING_ENCODE("hello", "IBM037", 0)
Output: "^^@>{Bytes}[-120, -123, -109, -109, -106]^^@>{Bytes} 'hello'"

=BYTE_STRING_ENCODE("hello", "IBM037", -1)
Output: "^^@>{Bytes}[-120, -123, -109, -109, -106]^^@>{Bytes} 'hello'"

=BYTE_STRING_ENCODE("hello", "IBM037", 6)
Output: "^^@>{Bytes}[-120, -123, -109, -109, -106, 64]^^@>{Bytes} 'hello '"

=BYTE_STRING_ENCODE("hello", "IBM037", 2)
Output: "^^@>{Bytes}[-120, -123]^^@>{Bytes} 'he'"

Note

AdapLink Data Exchange while writing data to AS400 for a column value starting with ^^@>{Bytes}, then the remaining integer values separated by comma is automatically converted to corresponding Java primitive byte array and send to AS400.

CLEAN

CLEAN(String s)

Removes all non-printable characters from the string (example: tab, newline).

Arguments:
  • s (java.lang.String) – Where ‘s’ cannot be null.
Return-type :

java.lang.String

Returns:

A string where all non-printable characters like tab, newline, etc. have been removed.

Example:

=CLEAN("Adap\t\t\t\t\tChain")
Output: "AdapChain"

COLLAPSE

COLLAPSE(String s)

Removes all white spaces from a string.

Arguments:
  • s (java.lang.String) – Where ‘s’ cannot be null.
Return-type :

java.lang.String

Returns:

A string where all white spaces have been removed.

Example:

=COLLAPSE ("   Where are you  ")
Output: "Whereareyou"

COMPRESS

COMPRESS(String s)

Replaces multiple white spaces with a single white space.

Arguments:
  • s (java.lang.String) – Where ‘s’ cannot be null.
Return-type :

java.lang.String

Returns:

A string where multiple white spaces has been replaced with a single white space.

Example:

=COMPRESS ("   Where         are you      ")
Output: " Where are you "

CONCAT

CONCAT(String s1, String s2, String s3, ..., String sn)

Concatenate two or more strings into one.

Arguments:
  • s1, s2, s3, ..., sn (java.lang.String) – Where s1, s2, s3, ..., sn cannot be null.
Return-type :

java.lang.String

Returns:

A concatenated string.

Example:

=CONCAT ("This ", "is a ", "concatenated", " value")
Output: "This is a concatenated value"

EXACT

EXACT(String s1, String s2)

Checks whether two strings are exactly identical or not.

Returns true or false.

Arguments:
  • s1 (java.lang.String) – Where ‘s1’ cannot be null.
  • s2 (java.lang.String) – Where ‘s2’ cannot be null.
Return-type :

java.lang.Boolean

Returns:

true if the string are exactly identical otherwise false.

Example:

=EXACT ("AdapChain", "AdapChain")
Output: true

=EXACT ("AdapChain", "adapChain")
Output: false

FIND

FIND(String s1, String s2[, Integer i])

Returns the starting position of one text string in another.

Arguments:
  • s1 (java.lang.String) – Where ‘s1’ is the string which is to be searched and cannot be null.
  • s2 (java.lang.String) – Where ‘s2’ is the search string and cannot be null.
  • i (java.lang.Integer) – (Optional) Where ‘i’ is the starting position from where the string has to be searched in ‘s1’.
Return-type :

java.lang.Integer

Returns:

The starting position of one text string in another.

Example:

=FIND("=", "AdapChain=Adaptive", 1)
Output: 10

=FIND("=", "AdapChain=Adaptive", 10)
Output: 10

=FIND("=","AdapChain=Adaptive", 11)
Output: 0

LCASE

LCASE(String s)

Changes the string to lowercase.

Arguments:
  • s (java.lang.String) – Where ‘s’ is a String which cannot be null.
Return-type :

java.lang.String

Returns:

The string converted to lowercase.

Example:

=LCASE("ARGUMENT")
Output: "argument"

LEFT

LEFT(String s, Integer i)

Returns the no of specified characters from the left.

Arguments:
  • s (java.lang.String) – Where ‘s’ is a String which cannot be null.
  • i (java.lang.Integer) – Where ‘i’ is an integer which cannot be null.
Return-type :

java.lang.String

Returns:

The number of specified characters from the left.

Example:

=LEFT("AdapChain", "2")
Output: "Ad"

=LEFT("AdapChain", 4)
Output: "Adap"

=LEFT("AdapChain", 0)
Output: ""

LPAD

LPAD(String s1, String s2, Integer i)

Adds the specified character to the left.

Arguments:
  • s1 (java.lang.String) – Where ‘s1’ is a String which cannot be null.
  • s2 (java.lang.String) – Where ‘s2’ is a String which cannot be null and length less than 1.
  • i (java.lang.Integer) – Where ‘i’ is an integer which cannot be less than 1.
Return-type :

java.lang.String

Returns:

A string with the padding to the left.

Example:

=LPAD"102", "0", "10")
Output: "0000000102"

LTRIM

LTRIM(String s)

Removes all leading white spaces from a string.

Arguments:
  • s (java.lang.String) – Input string. Should not be null.
Return-type :

java.lang.String

Returns:

The string ‘s’ after removing all leading white spaces.

Example:

=LTRIM("  Where are you   ")
Output: "Where are you   "

PROPER

PROPER(String s)

Changes the first letter of the string to capital and all other characters to lower.

Arguments:
  • s (java.lang.String) – Input string. Should not be null.
Return-type :

java.lang.String

Returns:

The string ‘s’ after converting the first letter of each word to uppercase and all other characters to lowercase.

Example:

=PROPER("AdapChaiN solutions pvt Ltd")
Output: "Adapchain Solutions Pvt Ltd"

REPEAT

REPEAT(String s, Integer i)

Repeat a text specified number of times

Arguments:
  • s (java.lang.String) – Input string. Should not be null.
  • i (java.lang.Integer) – Number of times to repeat the string ‘s’.
Return-type :

java.lang.String

Returns:

The string ‘s’ repeated ‘i’ times.

Example:

=REPEAT("101", "5")
Output: "101101101101101"

REPLACE

REPLACE(String s, Integer startIndex, Integer replaceCharCount, String replaceWith)

Replaces the no of characters from the given start index to no of characters with the given string.

Arguments:
  • s (java.lang.String) – Input string. Should not be null.
  • startIndex (java.lang.Integer) – Index in ‘s’ from which to start replacement.
  • replaceCharCount (java.lang.Integer) – Where ‘replaceCharCount’ is an Integer which cannot be null.
  • s2 (java.lang.String) – Replace with string. Should not be null.
Return-type :

java.lang.String

Returns:

The string after performing the replace.

Example:

=REPLACE("Adapc", "5", "5", "Chain")
Output: "Adapchain"

=REPLACE("SupplyChaIIn", "9", "4", "ain")
Output: "SupplyChain"

RPAD

RPAD(String s1, String s2, Integer i)

Adds the specified character to the left.

Arguments:
  • s1 (java.lang.String) – Where ‘s1’ is a String which cannot be null.
  • s2 (java.lang.String) – Where ‘s2’ is a String which cannot be null and length less than 1.
  • i (java.lang.Integer) – Where ‘i’ is an integer which cannot be less than 1.
Return-type :

java.lang.String

Returns:

A string with the padding to the right.

Example:

=RPAD("102", "0", "10")
Output: "1020000000"

RTRIM

RTRIM(String s)

Removes all trailing white spaces from a string.

Arguments:
  • s (java.lang.String) – String - where ‘s’ cannot be null.
Return-type :

java.lang.String

Returns:

A string after removing all trailing white spaces.

Example:

=RTRIM("  Where are you  ")
Output: "  Where are you"

STR_INDEX_OF

STR_INDEX_OF(String fullString, String searchString)

Returns the index within this string of the first occurrence of the specified substring.

If the string argument occurs as a searchString within fullString, then the index of the first character of the first such searchString is returned. If it does not occur as a searchString then -1 is returned.

Arguments:
  • fullString (java.lang.String) – Full string.
  • searchString (java.lang.String) – The substring for which to search.
Return-type :

java.lang.Integer

Returns:

The index of the first character of the first searchString found in fullString and -1 if it does not occur.

Example:

=STR_INDEX_OF("AdapChain", "Adap")
Output: 0

=STR_INDEX_OF("AdapChain", "Chain")
Output: 4

STREQ

STREQ(Object str1, Object str2[, boolean case_sensitive=false])

Converts the arguments to string and checks if they are equal (case insensitive by default). Any object can be passed, it is converted to string before comparing using String.valueOf().

Returns true if they are equal otherwise false.

Arguments:
  • str1 (java.lang.Object) – The first object - the object is converted to string.
  • str2 (java.lang.Object) – The second object - the object is converted to string.
  • case_sensitive (java.lang.Boolean) – (Optional) true implies perform case sensitive compare, by default this is false.
Return-type :

java.lang.Boolean

Returns:

true if they are equal otherwise false.

Example:

=STREQ(RIGHT("AdapChain", 5), "CHAIN", "false")
Output: true - because RIGHT("AdapChain", 5) returns "Chain"
   and case_sensitive has been set to false.

STRGT

STRGT(Object str1, Object str2[, boolean case_sensitive=false])

Converts the arguments to string and checks if the first argument is greater than the second argument (case insensitive by default). Any object can be passed, it is converted to string before comparing using String.valueOf().

Returns true if first string is greater than the second string.

Arguments:
  • str1 (java.lang.Object) – The first object - the object is converted to string.
  • str2 (java.lang.Object) – The second object - the object is converted to string.
  • case_sensitive (java.lang.Boolean) – (Optional) true implies perform case sensitive compare, by default this is false.
Return-type :

java.lang.Boolean

Returns:

true if first string is greater than the second string.

Example:

=STRGT("91", "101", "false")
Output: true - because 9 and 1 are compared first and 9 is lexicographically greater than 1.

STRGTEQ

STRGTEQ(Object str1, Object str2[, boolean case_sensitive=false])

Converts the arguments to string and checks if the first argument is greater than or equal to the second argument (case insensitive by default). Any object can be passed, it is converted to string before comparing using String.valueOf().

Returns true if first string is greater than or equal to the second string.

Arguments:
  • str1 (java.lang.Object) – The first object - the object is converted to string.
  • str2 (java.lang.Object) – The second object - the object is converted to string.
  • case_sensitive (java.lang.Boolean) – (Optional) true implies perform case sensitive compare, by default this is false.
Return-type :

java.lang.Boolean

Returns:

true if first string is greater than or equal to the second string.

Example:

=STRGTEQ("91", "101", "false")
Output: true - because 9 and 1 are compared first and 9 is lexicographically greater than 1.

STRLEN

STRLEN(String s)

Returns the number of characters in a string.

Para java.lang.String s:
 Input string. Should not be null.
Return-type :java.lang.Integer
Returns:The number of characters in a string.

Example:

=STRLEN("AdapChain")
Output: 9

STRLT

STRLT(Object str1, Object str2[, boolean case_sensitive=false])

Converts the arguments to string and checks if the first argument is less than the second argument (case insensitive by default). Any object can be passed, it is converted to string before comparing using String.valueOf().

Returns true if first string is less than the second string.

Arguments:
  • str1 (java.lang.Object) – The first object - the object is converted to string.
  • str2 (java.lang.Object) – The second object - the object is converted to string.
  • case_sensitive (java.lang.Boolean) – (Optional) true implies perform case sensitive compare, by default this is false.
Return-type :

java.lang.Boolean

Returns:

true if first string is less than the second string.

Example:

=STRLT("101", "91", "false")
Output: true - because 1 and 9 are compared first and 1 is lexicographically lesser than 9.

STRLTEQ

STRLTEQ(Object str1, Object str2[, Boolean case_sensitive=false])

Converts the arguments to string and checks if the first argument is less than or equal to the second argument (case insensitive by default). Any object can be passed, it is converted to string before comparing using String.valueOf().

Returns true if first string is less than or equal to the second string.

Arguments:
  • str1 (java.lang.Object) – The first object - the object is converted to string.
  • str2 (java.lang.Object) – The second object - the object is converted to string.
  • case_sensitive (java.lang.Boolean) – (Optional) true implies perform case sensitive compare, by default this is false.
Return-type :

java.lang.Boolean

Returns:

true if first string is less than or equal to the second string.

Example:

=STRLTEQ("101", "91", "false")
Output: true - because 1 and 9 are compared first and 1 is lexicographically lesser than 9.

SUBSTITUTE

SUBSTITUTE(String s1, String s2, String s3[, Integer i])

Replaces the text with the given text at the specific instance. If instance integer is null every instances of the string is replaced.

Arguments:
  • s1 (java.lang.String) – Where ‘s1’ is a String which cannot be null.
  • s2 (java.lang.String) – Where ‘s2’ is a Integer which cannot be null.
  • s3 (java.lang.String) – Where ‘s3’ is a String which cannot be null
  • i (java.lang.Integer) – (Optional) Number of instances to replace.
Return-type :

java.lang.String

Returns:

A string after performing replacement.

Example:

=SUBSTITUTE("1001", "0", "1", null)
Output: "1111"

=SUBSTITUTE("1001", "0", "1", "1")
Output: "1101"

SUBSTRING

SUBSTRING(String s, Integer x[, Integer l])

Returns part of the input string.

Arguments:
  • s (java.lang.String) – Input string. Should not be null.
  • x (java.lang.Integer) – The starting index, inclusive. x cannot be null, x cannot be greater than length of ‘s’ and x starts from ‘1’.
  • l (java.lang.Integer) – (Optional) The length of characters to be considered for the substring from ‘x’. If l > length of s complete string is returned from ‘x’.
Return-type :

java.lang.String

Returns:

Part of the input string.

Example:

=SUBSTRING("AdapChain", "1", "4")
Output: "Adap"

=SUBSTRING("AdapChain", new Integer[1], "30")
Output: "AdapChain"

=SUBSTRING("AdapChain","1","5")
Output: "AdapC"

=SUBSTRING("AdapChain","2")
Output: "dapChain"

=SUBSTRING("AdapChain", new Integer[2], null)
Output: "dapChain"

TRIM

TRIM(String s)

Removes all leading and trailing white spaces from a string.

Arguments:
  • s (java.lang.String) – String - where ‘s’ cannot be null.
Return-type :

java.lang.String

Returns:

A string after removing all leading and trailing white spaces.

Example:

=TRIM("  Where are you  ")
Output: "Where are you"

UCASE

UCASE(String s)

Changes the string to uppercase.

Arguments:
  • s (java.lang.String) – String - where ‘s’ cannot be null.
Return-type :

java.lang.String

Returns:

The string converted to uppercase.

Example:

=UCASE("argument")
Output: "ARGUMENT"

VALUE

VALUE(String s)

Converts a text string which is a number to a number.

Arguments:
  • s (java.lang.String) – String which can be converted to a number - where ‘s’ is a String which cannot be null.
Return-type :

java.lang.Number

Returns:

Returns a number by converting the input a text string which is a number to a number.

Example:

=VALUE("1.23")
Output: 1.23