Singleton
caplin.element.formatter

BracketsFormatter

Formats a negative number into a value with brackets.

BracketsFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to "(123)":

caplin.element.formatter.BracketsFormatter.format(-123, {})

See caplin.element.parser.BracketsParser for the complementary parser.

Constructor Summary

Attributes Name and Description
caplin.element.formatter.BracketsFormatter()

Method Summary

Attributes Name and Description
String format(Variant vValue, Map mAttributes)

Formats a negative number into a value with brackets.

Constructor Detail

caplin.element.formatter.BracketsFormatter()

Method Detail

String format(Variant vValue, Map mAttributes)

Formats a negative number into a value with brackets. Any form of suffix is assumed to be part of the number and is included in the conversion. Non-negative numeric values are unchanged.

For example, "-1.618" and "-2BIL" are converted to "(1.618)" and "(2BIL)" respectively.

Parameters
Variant vValue the number (String or Number type).
Map mAttributes (unused)
Returns
if number is negative, the absolute number surrounded by brackets, otherwise the original number.