This is an abstract base class for simple types. A simple type can format a raw model value based on the given format options, parse an external value based on the given format options and validate the raw model value based on the given constraints. An implementation of a simple type needs to implement #formatValue, #parseValue and #validateValue. If the raw value, which is the value in model representation, isn't already a JavaScript primitive type, subclasses must override #getModelFormat.
Method | Description |
---|---|
sap.ui.model.SimpleType.extend |
Creates a new subclass of class sap.ui.model.SimpleType with name
|
formatValue |
Formats the given raw value to an output value of the given target type. This happens according to the format options if the target type is |
getConstraints |
Returns a deep copy of the constraints of this type. The returned constraints can be used to create a new instance of the type with equivalent constraints. Subclasses may need to override this method. |
getFormatOptions |
Returns a deep copy of the format options of this type. The returned format options can be used to create a new instance of the type with equivalent format options. Subclasses may need to override this method. |
sap.ui.model.SimpleType.getMetadata |
Returns a metadata object for class sap.ui.model.SimpleType. |
getModelFormat |
Returns an object with You may return an instance of DateFormat or NumberFormat. The default implementation of the Example: |
parseValue |
Parses an external value of the given source type to the corresponding value in model representation. |
validateValue |
Validates whether a given raw value meets the defined constraints. This method does nothing if no constraints are defined. |
Creates a new subclass of class sap.ui.model.SimpleType 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.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 raw value to an output value of the given target type. This happens according to the format options if the target type is string
. If vValue
is not defined or null
, null
is returned.
Param | Type | DefaultValue | Description |
---|---|---|---|
vValue | any |
The value to be formatted |
|
sTargetType | string |
The target type; see Allowed Property Types |
Returns a deep copy of the constraints of this type. The returned constraints can be used to create a new instance of the type with equivalent constraints.
Subclasses may need to override this method.
Returns a deep copy of the format options of this type. The returned format options can be used to create a new instance of the type with equivalent format options.
Subclasses may need to override this method.
Returns an object with format
and parse
methods. format
converts the internal value which has a JavaScript primitive type or is a built-in object such as Date which can be used by a control to the raw value, and parse
converts the raw value to the internal value.
You may return an instance of DateFormat or NumberFormat.
The default implementation of the format
and parse
methods simply returns the given parameter. Subclasses of SimpleType should override this method if the raw value isn't already a JavaScript primitive type. The overwritten method must return an object which has the format
and parse
methods implemented.
Example:
If the type is related to a JavaScript Date
object, but the raw value isn't, this method should return an instance of DateFormat, which is able to convert between the raw value and a JavaScript Date
object.
Parses an external value of the given source type to the corresponding value in model representation.
Param | Type | DefaultValue | Description |
---|---|---|---|
vValue | any |
The value to be parsed |
|
sSourceType | string |
The type of the given value; see Allowed Property Types |