Class sap.ui.model.odata.type.StringModule: sap/ui/model/odata/type/String
This class represents the OData primitive type Edm.String
.
In both sap.ui.model.odata.v2.ODataModel and sap.ui.model.odata.v4.ODataModel this type is represented as a string
.
Since: 1.27.0.
Constructor Summary
new sap.ui.model.odata.type.String(oFormatOptions?, oConstraints?)Constructor for an OData primitive type
Edm.String
.Method Summary
sap.ui.model.odata.type.String.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.model.odata.type.String with name
sClassName
and enriches it with the information contained in oClassInfo
.sap.ui.model.odata.type.String.getMetadata()Returns a metadata object for class sap.ui.model.odata.type.String.
parseValue(vValue, sSourceType)Parses the given value which is expected to be of the given type to a string.
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.String(oFormatOptions?, oConstraints?)
Constructor for an OData primitive type
Edm.String
. Parameters:
{object} | oFormatOptions? | format options as defined in the interface of sap.ui.model.SimpleType; this type ignores them since it does not support any format options |
{object} | oConstraints? | constraints; validateValue throws an error if any constraint is violated |
{boolean|string} | oConstraints.isDigitSequence? | if true , the value is handled as a sequence of digits; while formatting leading zeros are removed from the value and while parsing the value is enhanced with leading zeros (if a maxLength constraint is given) or leading zeros are removed from the value (if no maxLength constraint is given); this constraint is supported since 1.35.0. To make this type behave as ABAP type NUMC, use oConstraints.isDigitSequence=true together with oConstraints.maxLength . |
{int|string} | oConstraints.maxLength? | the maximal allowed length of the string; unlimited if not defined |
{boolean|string} | oConstraints.nullable?, Default: true | if true , the value null is accepted |
Method Detail
sap.ui.model.odata.type.String.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.model.odata.type.String 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.String.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.model.odata.type.String.
Returns:
{sap.ui.base.Metadata} | Metadata object describing this class |
formatValue(sValue, sTargetType): string|number|boolean
Formats the given value to the given target type. If
isDigitSequence
constraint of this type is set to true
and the target type is any or string and the given value contains only digits, the leading zeros are truncated. Parameters:
{string} | sValue | the value to be formatted |
{string} | sTargetType | the target type; may be "any", "boolean", "float", "int" or "string". See sap.ui.model.odata.type for more information. |
Exceptions:
{sap.ui.model.FormatException} | if sTargetType is unsupported or the string cannot be formatted to the target type |
Returns:
{string|number|boolean} | 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 string. If
isDigitSequence
constraint of this type is set to true
and the parsed string is a sequence of digits, then the parsed string is either enhanced with leading zeros, if maxLength
constraint is given, or leading zeros are removed from parsed string. Parameters:
{string|number|boolean} | vValue | the value to be parsed, maps "" to null |
{string} | sSourceType | the source type (the expected type of vValue ). See sap.ui.model.odata.type for more information. |
Exceptions:
{sap.ui.model.ParseException} | if sSourceType is unsupported |
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 |