Class FormatNumberFunction
java.lang.Object
com.api.jsonata4java.expressions.functions.FunctionBase
com.api.jsonata4java.expressions.functions.FormatNumberFunction
From http://docs.jsonata.org/string-functions.html:
$formatNumber(number, picture [, options])
Casts the number to a string and formats it to a decimal representation as
specified by the picture string.
The behaviour of this function is consistent with the XPath/XQuery function
fn:format-number as defined in the XPath F&O 3.1 specification. The
picture string parameter defines how the number is formatted and has the same
syntax as fn:format-number.
The optional third argument options is used to override the default locale
specific formatting characters such as the decimal separator. If supplied,
this argument must be an object containing name/value pairs specified in the
decimal format section of the XPath F&O 3.1 specification.
Examples
$formatNumber(12345.6, '#,###.00')=="12,345.60" $formatNumber(1234.5678,
"00.000e0")=="12.346e2" $formatNumber(34.555, "#0.00;(#0.00)")=="34.56"
$formatNumber(-34.555, "#0.00;(#0.00)")=="(34.56)" $formatNumber(0.14,
"01%")=="14%" $formatNumber(0.14, "###pm", {"per-mille": "pm"})=="140pm"
$formatNumber(1234.5678, "①①.①①①e①", {"zero-digit": ""})=="①②.③④⑥e②"
-
Nested Class Summary
Nested classes/interfaces inherited from class com.api.jsonata4java.expressions.functions.FunctionBase
FunctionBase.CtxEvalResult -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintintcom.fasterxml.jackson.databind.JsonNodeinvoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx) Methods inherited from class com.api.jsonata4java.expressions.functions.FunctionBase
evalContext, getArgumentCount, getFunctionName
-
Field Details
-
ERR_BAD_CONTEXT
-
ERR_ARG1BADTYPE
-
ERR_ARG2BADTYPE
-
ERR_ARG3BADTYPE
-
ERR_ARG4BADTYPE
-
-
Constructor Details
-
FormatNumberFunction
public FormatNumberFunction()
-
-
Method Details
-
invoke
public com.fasterxml.jackson.databind.JsonNode invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx) - Specified by:
invokein classFunctionBase
-
getMaxArgs
public int getMaxArgs()- Specified by:
getMaxArgsin classFunctionBase
-
getMinArgs
public int getMinArgs()- Specified by:
getMinArgsin classFunctionBase
-
getSignature
- Specified by:
getSignaturein classFunctionBase
-