Package org.apache.juneau.commons.svl.functions
package org.apache.juneau.commons.svl.functions
Built-in
VarFunction catalog for
#{name(args...)} script-evaluation syntax.
Functions are organized by category with one Java file per category;
each individual function is a static nested class extending
TypedFunction.
Categories:
StringFunctions— substring, upper, lower, trim, replace, contains, format, split, join, pathToken, etc.TypeConversionFunctions— toInt, toLong, toDouble, toBool.ArithmeticFunctions— add, subtract, multiply, divide, modulo, min, max, abs.BooleanFunctions— and, or, not, xor, eq, neq, lt, lte, gt, gte.ConditionalFunctions— if, switch, coalesce, notEmpty.RegexFunctions— match, extract, replaceRegex.EncodingFunctions— base64Encode/Decode, urlEncode/Decode, htmlEscape/Unescape.DateFunctions— now, parseDate, formatDate.RandomFunctions— rand, randInt, randLong, randString, randChoice, uuid.JsonFunctions— jsonPath, get, keys, values, size.
See Also:
-
ClassesClassDescriptionArithmetic functions for the
#{...}script catalog.#{abs(a)}— returns the absolute value ofa.#{add(a, b)}— returnsa + b.#{divide(a, b)}— returnsa / b.#{max(a, b)}— returns the larger of two numbers.#{min(a, b)}— returns the smaller of two numbers.#{modulo(a, b)}— returnsa % b.#{multiply(a, b)}— returnsa * b.#{subtract(a, b)}— returnsa - b.Boolean-logic and comparison functions for the#{...}script catalog.#{and(a, b, ...)}— returns"true"only if all args are true.#{eq(a, b)}— string-equality.#{gt(a, b)}— numeric greater-than.#{gte(a, b)}— numeric greater-than-or-equal.#{lt(a, b)}— numeric less-than.#{lte(a, b)}— numeric less-than-or-equal.#{neq(a, b)}— string-inequality.#{not(a)}— returns the boolean negation ofa.#{or(a, b, ...)}— returns"true"if any arg is true.#{xor(a, b)}— returnsa XOR b.Conditional and routing functions for the#{...}script catalog.#{coalesce(a, b, ...)}— replacement for the legacy$CO{...}.#{if(cond, then, else)}— replacement for the legacy$IF{...}.#{notEmpty(s)}— replacement for the legacy$NE{...}.#{switch(value, case1, val1, case2, val2, ..., default)}— replacement for the legacy$SW{...}.Date/time functions for the#{...}script catalog.#{now()}— current epoch milliseconds (UTC).#{parseDate(s)}/#{parseDate(s, format)}— parses an ISO-8601 string or aDateTimeFormatter-pattern string to epoch milliseconds.Encoding / escaping functions for the#{...}script catalog.#{base64Decode(s)}— Base64-decodess(UTF-8 result).#{base64Encode(s)}— Base64-encodess(UTF-8).#{htmlEscape(s)}— escapes&,<,>,",'(the OWASP minimal HTML-injection-safe set).#{htmlUnescape(s)}— inverse ofEncodingFunctions.HtmlEscape.#{urlDecode(s)}— URL-form-decodes.#{urlEncode(s)}— URL-form-encodes (i.e.JSON-navigation functions for the#{...}script catalog.#{get(json, key)}— extractsjson[key](object) orjson[index](array, whenkeyparses as int).#{jsonPath(json, path)}/#{jsonPath(json, path, default)}— extracts a value via a slash-rooted path (e.g.#{keys(json)}— returns a JSON-array-shortcut string of an object's keys.#{size(json)}— returns the count: object key count, array length, string length, or0for null/primitives.#{values(json)}— returns a JSON-array-shortcut string of an object's values (or array elements).Random / UUID functions for the#{...}script catalog.#{rand()}— random double in[0.0, 1.0).#{randChoice(option1, option2, ...)}— variadic.#{randInt(max)}— random int in[0, max).#{randLong(min, max)}— random long in[min, max](inclusive both ends).#{randString(length)}— random alphanumeric[A-Za-z0-9]string oflengthcharacters.#{uuid()}— random UUID viaUUID.randomUUID().Regex functions for the#{...}script catalog.#{extract(s, regex)}/#{extract(s, regex, group)}— replacement for the legacy$PE{...}.#{match(s, regex)}— replacement for the legacy$PM{...}.#{replaceRegex(s, regex, replacement)}— replacement for the legacy$PR{...}.String-manipulation functions for the#{...}script catalog.#{concat(s1, s2, ...)}— variadic string concatenation.#{contains(s, substr)}— returns"true"or"false".#{endsWith(s, suffix)}— returns"true"or"false".#{format(pattern, args...)}—Java formatter-style formatting.#{join(separator, parts...)}— concatenatespartswithseparatorbetween each pair.#{len(s)}/#{len(s, delimiter)}— replacement for the legacy$LN{...}.#{lower(s)}— replacement for the legacy$LC{...}.#{pathToken(s)}— normalize a user-supplied path token for safe interpolation into apath=template.#{repeat(s, n)}— repeatssntimes.#{replace(s, target, replacement)}— literal (non-regex) string replacement.#{reverse(s)}— reverses the characters ofs.#{split(s, separator)}— splitsson the literalseparatorsubstring.#{startsWith(s, prefix)}— returns"true"or"false".#{stripLeading(s)}— strips leading whitespace.#{stripSlashes(s)}— strips leading and trailing/characters.#{stripTrailing(s)}— strips trailing whitespace.#{substring(s, start)}/#{substring(s, start, end)}— replacement for the legacy$ST{...}SubstringVar.#{trim(s)}— strips leading and trailing whitespace.#{upper(s)}— replacement for the legacy$UC{...}.Type-conversion functions for the#{...}script catalog.#{toBool(s)}— coercesstobooleanand renders as a String.#{toDouble(s)}— coercesstodoubleand renders as a String.#{toInt(s)}— coercesstointand renders as a String.#{toLong(s)}— coercesstolongand renders as a String.