Packagecom.esri.bacore
Classpublic class ValueFormatter
InheritanceValueFormatter Inheritance mx.formatters.NumberFormatter
Implements IValueFormatter

The ValueFormatter class provides the default implementation of interface.

See also

ValueFormat


Public Properties
 PropertyDefined By
  formatUnits : Function
A function providing units for a formatted value.
ValueFormatter
  removeUnits : Function
A function removing units from a formatted value.
ValueFormatter
Public Methods
 MethodDefined By
  
Initializes a new instance of the ValueFormatter class.
ValueFormatter
  
formatValue(value:Number, decimals:int):String
Converts a numeric value to a string representation with the required number of digits after the decimal point.
ValueFormatter
  
formatValueWithUnits(value:Number, decimals:int, valueType:BAValueType):String
Converts a numeric value to a string representation with the required number of digits after the decimal point provided with units if necessary.
ValueFormatter
  
parse(formattedValue:String):Number
Converts a formatted value to a numeric value.
ValueFormatter
Property Detail
formatUnitsproperty
formatUnits:Function

A function providing units for a formatted value.

The signature of this function is the following:

formatUnits(formattedValue:String, valueType:BAValueType):String;

It can add units to a formatted value and return the resulting string. For example, if the valueType is BAValueType.PERCENTAGE, this function can append the percent sign to the input formattedValue. If units are missing for the given value type, the function should return the input formattedValue.

If this function is null, units are not added to a value formatted with the FormatValueWithUnits method.


Implementation
    public function get formatUnits():Function
    public function set formatUnits(value:Function):void
removeUnitsproperty 
removeUnits:Function

Since : Community Analyst API for Flex 2.2.

A function removing units from a formatted value.

The signature of this function is the following:

removeUnits(formattedValueWithUnits:String):String;

It should test the formattedValueWithUnits parameter to contain units and return the value without units.


Implementation
    public function get removeUnits():Function
    public function set removeUnits(value:Function):void
Constructor Detail
ValueFormatter()Constructor
public function ValueFormatter()

Initializes a new instance of the ValueFormatter class.

Method Detail
formatValue()method
public function formatValue(value:Number, decimals:int):String

Converts a numeric value to a string representation with the required number of digits after the decimal point.

The base version formats a value using the format method of the base class with specified decimals as a precision value.

Parameters

value:Number — A numeric value to be converted.
 
decimals:int — The number of significant digits after the decimal point. Negative value means unknown number of digits.

Returns
String
formatValueWithUnits()method 
public function formatValueWithUnits(value:Number, decimals:int, valueType:BAValueType):String

Converts a numeric value to a string representation with the required number of digits after the decimal point provided with units if necessary.

The base version formats the value using the FormatValue method and after that adds units if necessary using the FormatUnits function associated with this formatter.

Parameters

value:Number — A numeric value to be converted.
 
decimals:int — The number of significant digits after the decimal point. Negative value means unknown number of digits.
 
valueType:BAValueType — Type of value.

Returns
String
parse()method 
public function parse(formattedValue:String):Number

Since : Community Analyst API for Flex 2.2.

Converts a formatted value to a numeric value.

The formatted value can contain units which will be removed if the removeUnits function is specified. After that the numeric value is parsed and the result is returned. If the value cannot be parsed, NaN is returned.

Parameters

formattedValue:String — String containing a formatted value.

Returns
Number — Numeric value or NaN.