Namespace sap.ui.model.odata.typeModule: sap/ui/model/odata/type/ODataType


The types in this namespace are simple types corresponding to OData primitive types for both OData V2 and OData V4 (see "4.4 Primitive Types").

They can be used in any place where simple types are allowed (and the model representation matches), but they are of course most valuable when used in bindings to a sap.ui.model.odata.v2.ODataModel or sap.ui.model.odata.v4.ODataModel.

Example:

  <Label text="ID"/>
  <Input value="{path : 'id', type : 'sap.ui.model.odata.type.String',
      constraints : {nullable : false, maxLength : 10}}"/>
  <Label text="valid through"/>
  <Input value="{path : 'validThrough', type : 'sap.ui.model.odata.type.DateTime',
      constraints : {displayFormat : 'Date'}}"/>

All types support formatting from the representation used in ODataModel ("model format") to various representations used by UI elements ("target type") and vice versa. Additionally they support validating a given value against the type's constraints.

The following target types may be supported:

TypeDescription
stringThe value is converted to a string, so that it can be displayed in an input field. Supported by all types.
booleanThe value is converted to a Boolean, so that it can be displayed in a checkbox. Only supported by sap.ui.model.odata.type.Boolean.
intThe value is converted to an integer (as number). May cause truncation of decimals and overruns. Supported by all numeric types.
floatThe value is converted to a number. Supported by all numeric types.
anyA technical format. The value is simply passed through. Only supported by format, not by parse. Supported by all types.

All constraints relevant for OData V2 may be given as strings besides their natural types (e.g. nullable : "false" or maxLength : "10"). This makes the life of template processors easier, but is not needed for OData V4.

Handling of null:

All types handle null in the same way. When formatting to string, it is simply passed through (and undefined becomes null, too). When parsing from string, it is also passed through. Additionally, String and Guid convert the empty string to null when parsing. validate decides based on the constraint nullable: If false, null is not accepted and leads to a (locale-dependent) ParseException.

This ensures that the user cannot clear an input field bound to an attribute with non-nullable type. However it does not ensure that the user really entered something if the field was empty before.

Namespaces & Classes
BooleanThis class represents the OData primitive type Edm.Boolean.
ByteThis class represents the OData primitive type Edm.Byte.
DateThis class represents the OData V4 primitive type Edm.Date.
DateTimeThis class represents the OData V2 primitive type Edm.DateTime.
DateTimeBaseThis is an abstract base class for the OData primitive types Edm.DateTime and Edm.DateTimeOffset.
DateTimeOffsetThis class represents the OData primitive type Edm.DateTimeOffset.
DecimalThis class represents the OData primitive type Edm.Decimal.
DoubleThis class represents the OData primitive type Edm.Double.
GuidThis class represents the OData primitive type Edm.Guid.
IntThis is an abstract base class for integer-based OData primitive types like Edm.Int16 or Edm.Int32.
Int16This class represents the OData primitive type Edm.Int16.
Int32This class represents the OData primitive type Edm.Int32.
Int64This class represents the OData primitive type Edm.Int64.
ODataTypeThis class is an abstract base class for all OData primitive types (see OData V4 Edm Types and OData V2 Edm Types).
RawThis class represents a placeholder for all unsupported OData primitive types.
SByteThis class represents the OData primitive type Edm.SByte.
SingleThis class represents the OData primitive type Edm.Single.
StringThis class represents the OData primitive type Edm.String.
TimeThis class represents the OData V2 primitive type Edm.Time.
TimeOfDayThis class represents the OData V4 primitive type Edm.TimeOfDay.