class sap.ui.model.odata.type.Decimal

Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/model/odata/type/Decimal
Application Component: CA-UI5-COR

This class represents the OData primitive type Edm.Decimal.

In both sap.ui.model.odata.v2.ODataModel and sap.ui.model.odata.v4.ODataModel this type is represented as a string. It never uses exponential format ("1e-5").


Constructor

Constructor for a primitive type Edm.Decimal.

new sap.ui.model.odata.type.Decimal(oFormatOptions?, oConstraints?)
Param Type Default Value Description
oFormatOptions? object

format options as defined in sap.ui.core.format.NumberFormat. In contrast to NumberFormat groupingEnabled defaults to true. Note that maxFractionDigits and minFractionDigits are set to the value of the constraint scale unless it is "variable". They can however be overwritten.

preserveDecimals? boolean true

by default decimals are preserved, unless oFormatOptions.style is given as "short" or "long"; since 1.89.0

oConstraints? object

constraints; validateValue throws an error if any constraint is violated

maximum? string

the maximum value allowed

maximumExclusive? boolean false

if true, the maximum value itself is not allowed

minimum? string

the minimum value allowed

minimumExclusive? boolean false

if true, the minimum value itself is not allowed

nullable? boolean string true

if true, the value null is accepted

precision? int string Infinity

the maximum number of digits allowed

scale? int string 0

the maximum number of digits allowed to the right of the decimal point; the number must be less than or equal to precision (if given). As a special case, "variable" is supported.

The number of digits to the right of the decimal point may vary from zero to scale, and the number of digits to the left of the decimal point may vary from one to precision minus scale. If scale is equal to precision, a single zero has to precede the decimal point.

The number is always displayed with exactly scale digits to the right of the decimal point (unless scale is "variable").


Methods Overview

Method Description
sap.ui.model.odata.type.Decimal.extend

Creates a new subclass of class sap.ui.model.odata.type.Decimal with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.odata.type.ODataType.extend.

formatValue

Formats the given value to the given target type. When formatting to "string" the type's constraint scale is taken into account.

sap.ui.model.odata.type.Decimal.getMetadata

Returns a metadata object for class sap.ui.model.odata.type.Decimal.

getName

Returns the type's name.

parseValue

Parses the given value, which is expected to be of the given type, to a decimal in string representation.

validateValue

Validates whether the given value in model representation is valid and meets the defined constraints.

sap.ui.model.odata.type.Decimal.extend

Creates a new subclass of class sap.ui.model.odata.type.Decimal with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.odata.type.ODataType.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

formatValue

Formats the given value to the given target type. When formatting to "string" the type's constraint scale is taken into account.

Param Type DefaultValue Description
sValue string

the value to be formatted, which is represented as a string in the model

sTargetType string

the target type; may be "any", "float", "int", "string", or a type with one of these types as its primitive type. See sap.ui.model.odata.type for more information.

sap.ui.model.odata.type.Decimal.getMetadata

Returns a metadata object for class sap.ui.model.odata.type.Decimal.

getName

Returns the type's name.

parseValue

Parses the given value, which is expected to be of the given type, to a decimal in string representation.

Param Type DefaultValue Description
vValue string number

the value to be parsed; the empty string and null are parsed to null

sSourceType string

the source type (the expected type of vValue); may be "float", "int", "string", or a type with one of these types as its primitive type. See sap.ui.model.odata.type for more information.

validateValue

Validates whether the given value in model representation is valid and meets the defined constraints.

Param Type DefaultValue Description
sValue string

the value to be validated