Class Functions
java.lang.Object
com.northconcepts.datapipeline.jsonata.Functions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NumberAbsolute value of a numberstatic ObjectAppend second argument to firststatic voidstatic NumberAverage functionstatic Stringbase64decode(String str) Base64 decode a stringstatic Stringbase64encode(String str) Base64 encode a stringstatic Objectstatic Objectstatic NumberRounds a number up to integerstatic BooleanTests if the str contains the tokenstatic NumberCount functionstatic StringdateTimeFromMillis(Number millis, String picture, String timezone) Converts milliseconds since the epoch to an ISO 8601 timestampstatic LongdateTimeToMillis(String timestamp, String picture) Converts an ISO 8601 timestamp to milliseconds since the epochstatic StringDecode a string from a urlstatic StringdecodeUrlComponent(String str) Decode a string from a component for a urlstatic ObjectReturns the values that appear in a sequence, with duplicates eliminated.static Liststatic StringEncode a string into a urlstatic StringencodeUrlComponent(String str) Encode a string into a component for a urlstatic voidstatic List<com.northconcepts.datapipeline.jsonata.Functions.RegexpMatch> evaluateMatcher(Pattern matcher, String str) Evaluate the matcher function against the str argstatic booleanDetermines if the argument is undefinedstatic ListCreate a map from an array of argumentsstatic NumberRounds a number down to integerstatic ObjectFold left functionstatic StringformatBase(Number value, Number _radix) Converts a number to a string using a specified number basestatic StringformatInteger(Number value, String picture) Formats an integer as specified by the XPath fn:format-integer function See https://www.w3.org/TR/xpath-functions-31/#func-format-integerstatic StringformatNumber(Number value, String picture, Map options) Formats a number into a decimal string representation using XPath 3.1 Finvalid input: '&O' fn:format-number specstatic ObjectCall helper for Javastatic ObjectfunctionClone(Object arg) Clones an objectstatic ObjectfunctionEval(String expr, Object focus) parses and evaluates the supplied expressionstatic MethodgetFunction(Class clz, String name) static intgetFunctionArity(Object func) static ListhofFuncArgs(Object func, Object arg1, Object arg2, Object arg3) Helper function to build the arguments to be supplied to the function arg of the HOFs map, filter, each, sift and singlestatic booleanstatic booleanstatic StringJoin an array of stringsstatic ListReturn keys for an objectstatic Stringstatic Integerlength of a stringstatic ObjectReturn value from an object for a given keystatic StringLowercase a stringstatic ListCreate a map from an array of argumentsMatch a string with a regex returning an array of object containing details of each matchstatic NumberMax functionstatic ObjectMerges an array of objects into a single object.static longmillis()static NumberMin functionstatic Booleanreturns the Boolean NOT of the argstatic Stringstatic NumberCast argument to numberstatic StringPad a string to a minimum width by adding characters to the start or endstatic NumberparseInteger(String value, String picture) parse a string containing an integer as specified by the picture stringstatic NumberRaises number to the power of the second numberstatic Numberrandom()Returns a random number 0 invalid input: '<'= n invalid input: '<' 1static Stringstatic ListReverses the order of items in an arraystatic Stringstatic NumberRound to half evenstatic ListRandomly shuffles the contents of an arraystatic ObjectApplies a predicate function to each key/value pair in an object, and returns an object containing only the key/value pairs that passed the predicatestatic ObjectGiven an array, find the single element matching a specified condition Throws an exception if the number of matching elements is not exactly onestatic ListImplements the merge sort (stable) with optional comparator functionstatic ObjectSplits an object into an array of object with one property eachstatic NumberSquare root of numberstatic StringStringify argumentsstatic StringSource = Jsonata4Java JSONataUtils.substrstatic StringCreate substring based on character number and lengthstatic StringsubstringAfter(String str, String chars) Create substring after a characterstatic StringsubstringBefore(String str, String chars) Create substring up until a characterstatic NumberSum functionstatic Stringstatic BooleanEvaluate an input and return a booleanstatic StringNormalize and trim whitespace within a stringstatic Stringstatic StringUppercase a stringstatic voidvalidateInput(Object arg) Validate input data types.static Listzip(Utils.JList<List> args) Convolves (zips) each value from a set of arrays
-
Constructor Details
-
Functions
public Functions()
-
-
Method Details
-
sum
Sum function -
count
Count function -
max
Max function -
min
Min function -
average
Average function -
string
Stringify arguments -
validateInput
Validate input data types. This will make sure that all input data can be processed.- Parameters:
arg-
-
substring
Create substring based on character number and length -
substr
Source = Jsonata4Java JSONataUtils.substr- Parameters:
str-start- Location at which to begin extracting characters. If a negative number is given, it is treated as strLength - start where strLength is the length of the string. For example, str.substr(-3) is treated as str.substr(str.length - 3)length- The number of characters to extract. If this argument is null, all the characters from start to the end of the string are extracted.- Returns:
- A new string containing the extracted section of the given string. If length is 0 or a negative number, an empty string is returned.
-
substringBefore
Create substring up until a character -
substringAfter
Create substring after a character -
lowercase
Lowercase a string -
uppercase
Uppercase a string -
length
length of a string -
trim
Normalize and trim whitespace within a string -
pad
Pad a string to a minimum width by adding characters to the start or end -
leftPad
-
rightPad
-
evaluateMatcher
public static List<com.northconcepts.datapipeline.jsonata.Functions.RegexpMatch> evaluateMatcher(Pattern matcher, String str) Evaluate the matcher function against the str arg -
contains
Tests if the str contains the token -
match
Match a string with a regex returning an array of object containing details of each match -
join
Join an array of strings -
replace
-
base64encode
Base64 encode a string -
base64decode
Base64 decode a string -
encodeUrlComponent
Encode a string into a component for a url- Throws:
UnsupportedEncodingException
-
encodeUrl
Encode a string into a url- Throws:
UnsupportedEncodingException
-
decodeUrlComponent
Decode a string from a component for a url- Throws:
UnsupportedEncodingException
-
decodeUrl
Decode a string from a url- Throws:
UnsupportedEncodingException
-
split
-
formatNumber
Formats a number into a decimal string representation using XPath 3.1 Finvalid input: '&O' fn:format-number spec -
formatBase
Converts a number to a string using a specified number base -
number
Cast argument to number- Throws:
NumberFormatExceptionJException
-
abs
Absolute value of a number -
floor
Rounds a number down to integer -
ceil
Rounds a number up to integer -
round
Round to half even -
sqrt
Square root of number -
power
Raises number to the power of the second number -
random
Returns a random number 0 invalid input: '<'= n invalid input: '<' 1 -
toBoolean
Evaluate an input and return a boolean -
not
returns the Boolean NOT of the arg -
getFunctionArity
-
hofFuncArgs
Helper function to build the arguments to be supplied to the function arg of the HOFs map, filter, each, sift and single -
funcApply
Call helper for Java- Parameters:
func-funcArgs-- Returns:
- Throws:
Throwable
-
map
Create a map from an array of arguments- Throws:
Throwable
-
filter
Create a map from an array of arguments- Throws:
Throwable
-
single
Given an array, find the single element matching a specified condition Throws an exception if the number of matching elements is not exactly one- Throws:
Throwable
-
zip
Convolves (zips) each value from a set of arrays -
foldLeft
Fold left function- Throws:
Throwable
-
keys
Return keys for an object -
exists
Determines if the argument is undefined -
spread
Splits an object into an array of object with one property each -
merge
Merges an array of objects into a single object. Duplicate properties are overridden by entries later in the array -
reverse
Reverses the order of items in an array -
each
- Throws:
Throwable
-
error
-
assertFn
-
type
-
sort
Implements the merge sort (stable) with optional comparator function -
shuffle
Randomly shuffles the contents of an array -
distinct
Returns the values that appear in a sequence, with duplicates eliminated. -
sift
Applies a predicate function to each key/value pair in an object, and returns an object containing only the key/value pairs that passed the predicate- Throws:
Throwable
-
append
Append second argument to first -
isLambda
-
lookup
Return value from an object for a given key -
test
-
getFunction
-
call
public static Object call(Class clz, Object instance, String name, List<Object> args) throws Throwable - Throws:
Throwable
-
call
- Throws:
Throwable
-
dateTimeToMillis
Converts an ISO 8601 timestamp to milliseconds since the epoch- Throws:
ParseException
-
isNumeric
-
dateTimeFromMillis
Converts milliseconds since the epoch to an ISO 8601 timestamp -
formatInteger
Formats an integer as specified by the XPath fn:format-integer function See https://www.w3.org/TR/xpath-functions-31/#func-format-integer -
parseInteger
parse a string containing an integer as specified by the picture string- Throws:
ParseExceptionJException
-
functionClone
Clones an object -
functionEval
parses and evaluates the supplied expression -
now
-
millis
public static long millis()
-