This class represents the Unit
composite type with the parts measure, unit, and unit customizing. The type may only be used for measure and unit parts from a sap.ui.model.odata.v4.ODataModel or a sap.ui.model.odata.v2.ODataModel. The measure part is formatted according to the customizing for the unit. Use the result of the promise returned by sap.ui.model.odata.v4.ODataMetaModel#requestUnitsOfMeasure for OData V4 or by sap.ui.model.odata.ODataMetaModel#requestUnitsOfMeasure for OData V2 as unit customizing part. If no unit customizing is available, UI5's default formatting applies.
Constructor for a Unit
composite type.
new sap.ui.model.odata.type.Unit(oFormatOptions?, oConstraints?, aDynamicFormatOptionNames?)
Param | Type | Default Value | Description |
---|---|---|---|
oFormatOptions? | object | See parameter |
|
customUnits? | object | Not supported; the type derives this from its unit customizing part. |
|
parseAsString? | boolean | true | Whether the measure is parsed to a string; set to |
preserveDecimals? | boolean | true | By default decimals are preserved, unless |
unitOptional? | boolean | Whether the measure is parsed if no unit is entered; defaults to |
|
emptyString? | any | 0 | Defines how an empty string is parsed into the measure. With the default value |
oConstraints? | object | Only the 'skipDecimalsValidation' constraint is supported. Constraints are immutable, that is, they can only be set once on construction. |
|
skipDecimalsValidation? | boolean | false | Whether to skip validation of the number of decimals based on the code list customizing; since 1.93.0 |
aDynamicFormatOptionNames? | string[] | Not supported |
Method | Description |
---|---|
sap.ui.model.odata.type.Unit.extend |
Creates a new subclass of class sap.ui.model.odata.type.Unit with name
|
formatValue |
Formats the given values of the parts of the |
sap.ui.model.odata.type.Unit.getMetadata |
Returns a metadata object for class sap.ui.model.odata.type.Unit. |
getName |
Returns the type's name. |
parseValue |
Parses the given string value to an array containing measure and unit.
|
validateValue |
Validates whether the given value in model representation as returned by #parseValue is valid and meets the conditions of this type's unit customizing. |
Creates a new subclass of class sap.ui.model.odata.type.Unit 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.type.Unit.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 |
Formats the given values of the parts of the Unit
composite type to the given target type.
Param | Type | DefaultValue | Description |
---|---|---|---|
aValues | any[] |
Array of part values to be formatted; contains in the following order: measure, unit, unit customizing. The first call to this method where all parts are set determines the unit customizing; subsequent calls use this customizing, so that the corresponding part may be omitted. Changes to the unit customizing part after this first method call are not considered: The unit customizing for this |
|
sTargetType | string |
The target type; must be "string" or a type with "string" as its primitive type. See sap.ui.model.odata.type for more information. |
Returns a metadata object for class sap.ui.model.odata.type.Unit.
Parses the given string value to an array containing measure and unit.
References:
Param | Type | DefaultValue | Description |
---|---|---|---|
vValue | string |
The value to be parsed |
|
sSourceType | string |
The source type (the expected type of |
|
aCurrentValues | any[] |
Not used |
Validates whether the given value in model representation as returned by #parseValue is valid and meets the conditions of this type's unit customizing.
Param | Type | DefaultValue | Description |
---|---|---|---|
aValues | any[] |
An array containing measure and unit in this order, see return value of #parseValue |