Util

object Util

Common Utilities. Some of the functions are port from JavaScript.

Author

Chan Wai Shing @gmail.com>

Functions

Link copied to clipboard
fun getVariableValueAsBoolean(var: Any?): Boolean

Treat a variable as an boolean in JavaScript style. Note this function can only handle string, integer and boolean currently. All other data type, if null, return false, not null return true.

Link copied to clipboard
fun getVariableValueAsInteger(var: Any?): Int

Treat a variable as an integer in JavaScript style. Note this function can only handle integer and boolean currently.

Link copied to clipboard
fun join(strings: List<String>): String
fun join(strings: Array<String>?, delimiter: String? = null): String

Join the strings into one string.

fun join(strings: List<String>?, delimiter: String?): String

Join the strings into one string with delimiter in between.

Link copied to clipboard
fun match(    regex: Regex,     string: String,     isGlobal: Boolean): MutableList<String>

Get all the matches for string compiled by pattern. If isGlobal is true, the return results will only include the group 0 matches. It is similar to string.match(regexp) in JavaScript.

Link copied to clipboard
fun removeDuplicates(decorations: List<Any>?, source: String?): List<Any>

Remove identical adjacent tags from decorations.

Link copied to clipboard
fun test(pattern: Regex, string: String): Boolean

Test whether the string has at least one match by pattern.