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.Small collection helpers:listandtake.#{list(a, b, ...)}— a list of the arguments;list()is empty.#{take(list, n)}— the firstnelements oflist(all of them if it is shorter).Conditional and routing functions for the#{...}script catalog.#{coalesce(a, b, ...)}— replacement for the legacyCOvariable.#{if(cond, then, else)}— replacement for the legacyIFvariable.#{notEmpty(s)}— replacement for the legacyNEvariable.#{switch(value, case1, val1, case2, val2, ..., default)}— replacement for the legacySWvariable.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(x)}— returns the count as a number: element count of a collection or map value, otherwise (for JSON text) 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).Reserved$op.*operator functions targeted by the compiled expression grammar.$op.add.$op.and.$op.div.$op.elvis.$op.eq.$op.ge.$op.gt.$op.le.$op.lt.$op.matches.$op.mod.$op.mul.$op.ne.$op.neg.$op.not.$op.or.$op.pos.Registered stub for the evaluator-only$op.projectoperator.Registered stub for the evaluator-only$op.selectoperator.$op.sub.$op.ternary.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 legacyPEvariable.#{match(s, regex)}— replacement for the legacyPMvariable.#{replaceRegex(s, regex, replacement)}— replacement for the legacyPRvariable.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 legacyLNvariable.#{lower(s)}— replacement for the legacyLCvariable.#{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 legacySTSubstringVar.#{trim(s)}— strips leading and trailing whitespace.#{upper(s)}— replacement for the legacyUCvariable.Structure-producing and collection functions:ul,ol,block,table.#{block(x)}.#{ol(items...)}or#{ol(list)}.#{table(headerList, rowsList)}; each row is a list (or collection).#{ul(items...)}or#{ul(list)}.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.