Class sap.ui.model.odata.type.DecimalModule: sap/ui/model/odata/type/Decimal
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").
Since: 1.27.0.
Constructor Summary
new sap.ui.model.odata.type.Decimal(oFormatOptions?, oConstraints?)Constructor for a primitive type
Edm.Decimal
.Method Summary
sap.ui.model.odata.type.Decimal.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.odata.type.Decimal with name
sClassName
and enriches it with the information contained in oClassInfo
.sap.ui.model.odata.type.Decimal.getMetadata()Returns a metadata object for class sap.ui.model.odata.type.Decimal.
parseValue(vValue, sSourceType)Parses the given value, which is expected to be of the given type, to a decimal in
string
representation.validateValue(sValue)Validates whether the given value in model representation is valid and meets the defined constraints.
Methods borrowed from class sap.ui.model.odata.type.ODataType
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.model.odata.type.Decimal(oFormatOptions?, oConstraints?)
Constructor for a primitive type
Edm.Decimal
. Parameters:
{object} | oFormatOptions? | 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. |
{object} | oConstraints? | constraints; validateValue throws an error if any constraint is violated |
{boolean|string} | oConstraints.nullable?, Default: true | if true , the value null is accepted |
{int|string} | oConstraints.precision?, Default: Infinity | the maximum number of digits allowed in the property’s value |
{int|string} | oConstraints.scale? | the maximum number of digits allowed to the right of the decimal point; the number must be less than 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 The number is always displayed with exactly |
Method Detail
sap.ui.model.odata.type.Decimal.extend(sClassName, oClassInfo?, FNMetaImpl?): function
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.
Parameters:
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
Returns:
{function} | Created class / constructor function |
sap.ui.model.odata.type.Decimal.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.odata.type.Decimal.
Returns:
{sap.ui.base.Metadata} | Metadata object describing this class |
formatValue(sValue, sTargetType): number|string
Formats the given value to the given target type. When formatting to "string" the type's constraint
scale
is taken into account. Parameters:
{string} | sValue | the value to be formatted, which is represented as a string in the model |
{string} | sTargetType | the target type; may be "any", "float", "int" or "string". See sap.ui.model.odata.type for more information. |
Exceptions:
{sap.ui.model.FormatException} | if sTargetType is unsupported |
Returns:
{number|string} | the formatted output value in the target type; undefined or null are formatted to null |
parseValue(vValue, sSourceType): string
Parses the given value, which is expected to be of the given type, to a decimal in
string
representation. Parameters:
{string|number} | vValue | the value to be parsed; the empty string and null are parsed to null |
{string} | sSourceType | the source type (the expected type of vValue ); may be "float", "int" or "string". See sap.ui.model.odata.type for more information. |
Exceptions:
{sap.ui.model.ParseException} | if sSourceType is unsupported or if the given string cannot be parsed to a Decimal |
Returns:
{string} | the parsed value |
validateValue(sValue): void
Validates whether the given value in model representation is valid and meets the defined constraints.
Parameters:
{string} | sValue | the value to be validated |
Exceptions:
{sap.ui.model.ValidateException} | if the value is not valid |