Difference between revisions of "Extensions.DataType.Enumeration"
Jump to navigation
Jump to search
(Edited by Ngoc Tran.) |
|||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{DISPLAYTITLE:Data Type '''Enumeration'''}}[[Category:DataType]][[Category: | + | {{DISPLAYTITLE:Data Type '''Enumeration'''}}[[Category:DataType]][[Category:DataType]] |
== Classification == | == Classification == | ||
− | {{ClassificationDataType | Enumeration | User-defined enumeration | [[Core.DataTypes.SimpleDataType|Simple Data Type]] |[[Core.DataTypes.SimpleDataType.SimpleType|SimpleType]]| | + | {{ClassificationDataType | Enumeration | User-defined enumeration | [[Core.DataTypes.SimpleDataType|Simple Data Type]] |[[Core.DataTypes.SimpleDataType.SimpleType|SimpleType]]| DefaultValue=The first enumeration element | Literal=Yes }} |
== Description == | == Description == | ||
− | + | An '''Enumeration''' consists of a set of named constants called enumeration elements. Each enumeration element assigns a unique name to a unique '''IntergerLiteral''', so that the name can be used as an '''EnumerationLiteral''' inside OTX instead of the integer value. The simple term of the enumerator value is its integer value. Thus, for relational terms, the integer values of the specific enumerator value are used. | |
+ | ==Literal== | ||
+ | '''Enumeration''' values are named constants. Therefore the '''EnumerationLiteral''' term will return a reference to the value of the constant that has the name provided in the EnumerationLiteral's elementName field. | ||
+ | <syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | ||
+ | EnumerationSignature1.EnumerationElement1 | ||
+ | </syntaxhighlight> | ||
{{ConversionTable | | {{ConversionTable | | ||
Line 11: | Line 16: | ||
String=Returns the name of current enumeration element | StringSample=<tt>String s = ToString(enumerationSignatureVariable); // Returns "EnumerationElement1"</tt> | String=Returns the name of current enumeration element | StringSample=<tt>String s = ToString(enumerationSignatureVariable); // Returns "EnumerationElement1"</tt> | ||
}} | }} | ||
+ | |||
+ | == Checker Rules == | ||
+ | [[Extensions.DataType.DataTypeChk002|DataType_Chk002]] <br /> | ||
+ | [[Core.Validation.CoreChk053|Core_Chk053]] | ||
+ | |||
+ | ==Sample== | ||
+ | <syntaxhighlight lang="java" enclose="div" style="font-size: medium;"> | ||
+ | package DataType.EnumerationSignature EnumerationSignature1(Integer EnumerationElement1 = 3, Integer EnumerationElement2 = 5, Integer EnumerationElement3 = 7, Integer EnumerationElement4 = 9); | ||
+ | |||
+ | /// Global Declarations | ||
+ | |||
+ | public procedure main() | ||
+ | { | ||
+ | /// Local Declarations | ||
+ | |||
+ | EnumerationSignature1 Enumeration1 = EnumerationSignature1.EnumerationElement1; | ||
+ | } | ||
+ | </syntaxhighlight> |
Latest revision as of 03:07, 11 November 2019
Classification
Name | Enumeration |
Short Description | User-defined enumeration |
Class | Simple Data Type |
Base Data Type | SimpleType |
Default Value | The first enumeration element |
Provide a Literal | Yes |
SpecifiedBy | ISO 13209-3 |
Standard Compliant | Yes |
Description
An Enumeration consists of a set of named constants called enumeration elements. Each enumeration element assigns a unique name to a unique IntergerLiteral, so that the name can be used as an EnumerationLiteral inside OTX instead of the integer value. The simple term of the enumerator value is its integer value. Thus, for relational terms, the integer values of the specific enumerator value are used.
Literal
Enumeration values are named constants. Therefore the EnumerationLiteral term will return a reference to the value of the constant that has the name provided in the EnumerationLiteral's elementName field.
EnumerationSignature1.EnumerationElement1
Core Conversion
The following table shows the rules for conversion to another data type:
Conversion | Result | Sample |
ToBoolean | Undefined (should not be used) | |
ToInteger | Returns the integer value of the enumeration term | Integer n = ToInteger(enumerationSignatureVariable); // Returns 12 (supposed the current enumeration element's value is 12) |
ToFloat | Undefined (should not be used) | |
ToString | Returns the name of current enumeration element | String s = ToString(enumerationSignatureVariable); // Returns "EnumerationElement1" |
ToByteField | Undefined (should not be used) |
Checker Rules
Sample
package DataType.EnumerationSignature EnumerationSignature1(Integer EnumerationElement1 = 3, Integer EnumerationElement2 = 5, Integer EnumerationElement3 = 7, Integer EnumerationElement4 = 9);
/// Global Declarations
public procedure main()
{
/// Local Declarations
EnumerationSignature1 Enumeration1 = EnumerationSignature1.EnumerationElement1;
}