12-mapping_ttcn3_data_types_to_java_constructs.adoc 124 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
[[mapping-ttcn-3-data-types-to-java-constructs]]
= Mapping TTCN–3 Data Types to Java Constructs
:table-number: 7
:toc:

On the Java side the TTCN–3 language elements of the test suite are individually mapped into more or less equivalent Java constructs. The data types are mapped to Java classes, the test cases become Java functions, and so on. In order to write a Test Port, it is inevitable to be familiar with the internal representation format of TTCN–3 data types and values. This section gives an overview about the data types and their equivalent Java constructs.

[[mapping-of-names-and-identifiers]]
== Mapping of Names and Identifiers

In order to identify the TTCN–3 language elements in the generated Java program properly, the names of test suite are translated to Java identifiers according to the following simple rules.

If the TTCN–3 identifier does not contain any underscore (_) character, its equivalent Java identifier will be the same. For example, the TTCN–3 variable `MyVar` will be translated to a Java variable called `MyVar`.

If the TTCN–3 identifier contains one or more underscore characters, each underscore character will be duplicated in the Java identifier. So the TTCN–3 identifier `My_Long_Name` will be mapped to a Java identifier called `My\__Long__Name`.

The idea behind this name mapping is that we may freely use the Java identifiers containing one underscore character in the generated code and in the Test Ports as well. Otherwise name clashes might happen (and to keep in line with the {cpp} side of the toolset and its already existing large amount of code). Furthermore, the generated Java language elements fulfill the condition that the scope of a translated Java identifier is identical as the scope of the original TTCN–3 identifier.

The identifiers that are keywords of Java but not keywords in TTCN–3 are mapped to themselves, but a single underscore character is appended at the end (for example `for` becomes `for_`). The same rule applies to the all-uppercase identifiers that are used in the Base Library: identifier `TitanInteger` in TTCN–3 becomes `TitanInteger_` in Java, `TRUE` footnote:[The built-in `verdict` and `boolean` constants in TTCN–3 shall be written with all lowercase letters, such as true or pass. Although previous compiler versions have accepted `TRUE` or `PASS` as well, these words are treated by the compiler as regular identifiers as specified in the standard.] is mapped to `TRUE_`, etc.

FIXME update list of words
Here is the complete list (in alphabetical order) of the identifiers that are handled in such special way:asm, auto, bitand, bitor, bool, break, case, class, compl, continue, delete, double, enum, explicit, export, friend, inline, int, ischosen, long, main, mutable, namespace, new, operator, private, protected, public, register, short, signed, static, stderr, stdin, stdout, struct, switch, this, throw, try, typedef, typeid, typename, unsigned, using, virtual, void, volatile, ADDRESS, BITSTRING, BOOLEAN, CHAR, CHARSTRING, COMPONENT, DEFAULT, ERROR, FAIL, FALSE, FLOAT, HEXSTRING, INCONC, INTEGER, NONE, OBJID, OCTETSTRING, PASS, PORT, TIMER, TRUE, VERDICTTYPE.

The identifiers that are the names of common classes of the Java library (such as `System`, `Map`, ) should be avoided in TTCN–3 modules. The name clashes clashes might create problems during the implementation of external functions and testports.

Note that these name mapping rules apply to *all* TTCN–3 identifiers, including module, Test Port, type, field, variable and function names.

== Modules

The Java code generator generates a Java class for every TTCN–3 and ASN.1 module. All Java definitions that belong to the module (including Test Port classes and external functions) are placed in that class. The name of the class is derived from the module identifier according to the rules described in <<mapping-of-names-and-identifiers, Mapping of Names and Identifiers>>.

When accessing a Java entity that belongs to a different module than the referring Test Port or external function is in the reference has to be prefixed with the class of the referenced module and the class of the referenced module being imported. For example, to access the Java class that realizes type `MyType` defined in `MyModule1` from a Test Port that belongs to module `MyModule2` the reference shall be written as `MyModule1.MyType`.

[[predefined-ttcn-3-data-types]]
== Predefined TTCN–3 Data Types

in the TTCN–3 Base Library all basic data types of TTCN–3 were implemented as Java classes.
This is because:
* The TTCN–3 executor must know whether a variable has a valid value or not because sending an unbound value must result in a dynamic test case error.
* Complex types (like a record or set) have no equivalents in Java.
* Encoding and decoding of types in not present in Java types.
* etc.

This section describes the member functions of these classes.

46 47
WARNING: The toString of the built in and generated types is not considered part of the public API for Test Port development. Its implementation might be subject to change without notice. Please do not use it.

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
=== `Integer`

The TTCN–3 type `integer` is implemented in class `TitanInteger`. +
The class `TitanInteger` has the following public member functions:

.Public member functions of the class `TitanInteger`
[cols="20%,60%,20%",]
|==================================================
2+^.^|*Member functions* |*Notes*
.5+^.^|_Constructors_
|`TitanInteger()` |Initializes to unbound value.
|`TitanInteger(final int otherValue)` |Initializes to a given value.
|`TitanInteger(final BigInteger otherValue)` |Initializes to a given value.
|`TitanInteger(final TitanInteger otherValue)` |Copy constructor.
|`TitanInteger(final String otherValue)` |Initializes with the String representation of an integer.
.4+^.^|_Assignment operators_
|`TitanInteger operator_assign(final int otherValue)` | Sets to given value.
|`TitanInteger operator_assign(final BigInteger otherValue)` | Sets to given value.
|`TitanInteger operator_assign(final TitanInteger otherValue)` |Sets to given value.
|`TitanInteger operator_assign(final Base_Type otherValue)` |Sets to given value.
.7+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
69 70
| boolean operator_equals(final int otherValue) | Returns true if equals.
| boolean operator_equals(final BigInteger otherValue) | and false otherwise.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
| boolean operator_equals(final TitanInteger otherValue) |
| boolean operator_equals(final Base_Type otherValue)  |
| boolean operator_not_equals(final int otherValue)  |
| boolean operator_not_equals(final BigInteger otherValue)  |
| boolean operator_not_equals(final TitanInteger otherValue)  |
.12+^.^|_Comparison operators_
| boolean is_less_than(final int otherValue)  |
| boolean is_less_than(final BigInteger otherValue)  |
| boolean is_less_than(final TitanInteger otherValue)  |
| boolean is_less_than_or_equal(final int otherValue)  |
| boolean is_less_than_or_equal(final BigInteger otherValue)  |
| boolean is_less_than_or_equal(final TitanInteger otherValue)  |
| boolean is_greater_than(final int otherValue)  |
| boolean is_greater_than(final BigInteger otherValue) |
| boolean is_greater_than(final TitanInteger otherValue)  |
| boolean is_greater_than_or_equal(final int otherValue)  |
| boolean is_greater_than_or_equal(final BigInteger otherValue)  |
| boolean is_greater_than_or_equal(final TitanInteger otherValue)  |
.20+^.^|_Arithmetic operators_
| TitanInteger add() |Unary plus.
| TitanInteger sub() |Unary minus.
| TitanInteger add(final int other_value) |Addition.
| TitanInteger add(final BigInteger other_value) |
| TitanInteger add(final TitanInteger other_value) |
| TitanInteger sub(final int other_value) |Subtraction.
| TitanInteger sub(final BigInteger other_value) |
| TitanInteger sub(final TitanInteger other_value) |
| TitanInteger mul(final int other_value) |Multiplication.
| TitanInteger mul(final BigInteger other_value) |
| TitanInteger mul(final TitanInteger other_value)|
| TitanInteger div(final int other_value) |Integer division.
| TitanInteger div(final BigInteger other_value) |
| TitanInteger div(final TitanInteger other_value) |
| TitanInteger rem(final int other_value) |remainder of the division.
| TitanInteger rem(final BigInteger other_value) |
| TitanInteger rem(final TitanInteger other_value) |
| TitanInteger mod(final int other_value) |modulo of the division.
| TitanInteger mod(final BigInteger other_value) |
| TitanInteger mod(final TitanInteger other_value) |
.3+^.^|_Casting operator_
| int get_int() |Returns the value.
| long get_long() |Returns the value.
| BigInteger get_BigInteger() |Returns the value.
.8+^.^|_Other member functions_
| `boolean is_native()` |is the value native int.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log.
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.
|==================================================

The comparison, arithmetic and shifting operators are also available as global functions for that case when the left side is `int` and the right side is `TitanInteger`. Using the value of an unbound variable for anything will cause dynamic test case error.

The `get_int()` is applicable only to `TitanInteger` objects holding a signed value with at most 31 useful bits, since in Java the native `int` type is 32-bit large including the sign bit. Being used on an `TitanInteger` object holding a bigger (for example a 32-bit unsigned) value will result in run-time error.

Please note that if the value stored in a `TitanInteger` object is too big (that is, it cannot be represented as a `int`) the value returned by `get_long()` will contain only the lowest 64 bits of the original value.

In addition, the following static functions are available for modulo division. These functions return the result of `mod` and `rem` operations according to TTCN–3 semantics.
[source]
----
TitanInteger mod(final TitanInteger left_value, final TitanInteger right_value);
TitanInteger mod(final TitanInteger left_value, final int right_value);
TitanInteger mod(final int left_value, final TitanInteger right_value);
TitanInteger mod(final int left_value, int right_value);

TitanInteger rem(final TitanInteger left_value, final TitanInteger right_value);
TitanInteger rem(final TitanInteger left_value, final int right_value);
TitanInteger rem(final int left_value, final TitanInteger right_value);
TitanInteger rem(final int left_value, final int right_value);
----

Other operators (static functions):
[source]
----
TitanInteger add(final int int_value, final TitanInteger other_value);  // Add
TitanInteger sub(final int int_value, final TitanInteger other_value);  // Subtract
TitanInteger mul(final int int_value, final TitanInteger other_value);  // Multiply
TitanInteger div(final int int_value, final TitanInteger other_value);  // Divide
boolean operator_equals(final int intValue, final TitanInteger otherValue); // Equal
boolean operator_not_equals(final int intValue, final TitanInteger otherValue); // Not equal
boolean is_less_than(final int intValue, final TitanInteger otherValue);  // Less than
boolean is_greater_than(final int intValue, final TitanInteger otherValue);  // More than
----

=== `Float`

The TTCN–3 type `float` is implemented in class `TitanFloat`. +
The class `TitanFloat` has the following public member functions:

.Public member functions of the class `TitanFloat`

[width="100%",cols="20%,60%,20%"]
|=================================================================================================
2+^.^|*Member functions* |*Notes*
.4+^.^|_Constructors_
|`TitanFloat()` |Initializes to unbound value.
|`TitanFloat(final double otherValue)` |Initializes to a given value.
|`TitanFloat(final Ttcn3Float otherValue)`|
|`TitanFloat(final TitanFloat otherValue)` |Copy constructor.
.4+^.^|Assignment operators
|`TitanFloat operator_assign(final double otherValue)`  |Assigns the given value
|`TitanFloat operator_assign(final Ttcn3Float otherValue)` |and sets the bound flag.
|`TitanFloat operator_assign(final TitanFloat otherValue)` |
|`TitanFloat operator_assign(final Base_Type otherValue)` |
.19+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
179 180
|boolean operator_equals(final double otherValue) |Returns true if equals
|boolean operator_equals(final Ttcn3Float otherValue) |and false otherwise.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
|boolean operator_equals(final TitanFloat otherValue)  |
|boolean operator_equals(final Base_Type otherValue)  |
|boolean operator_not_equals(final double otherValue)  |
|boolean operator_not_equals(final Ttcn3Float otherValue) |
|boolean operator_not_equals(final TitanFloat otherValue)  |
|boolean is_less_than(final double otherValue)  |
|boolean is_less_than(final Ttcn3Float otherValue)   |
|boolean is_less_than(final TitanFloat otherValue)   |
|boolean is_less_than_or_equal(final double otherValue)  |
|boolean is_less_than_or_equal(final Ttcn3Float otherValue)  |
|boolean is_less_than_or_equal(final TitanFloat otherValue)  |
|boolean is_greater_than(final double otherValue)  |
|boolean is_greater_than(final Ttcn3Float otherValue)  |
|boolean is_greater_than(final TitanFloat otherValue)  |
|boolean is_greater_than_or_equal(final double otherValue)  |
|boolean is_greater_than_or_equal(final Ttcn3Float otherValue) |
|boolean is_greater_than_or_equal(final TitanFloat otherValue)  |
.14+^.^|_Arithmetic operators_
|TitanFloat add()  |Unary plus.
|TitanFloat sub()  |Unary minus.
|TitanFloat add(final double other_value) |Addition.
|TitanFloat add(final Ttcn3Float other_value)  |
|TitanFloat add(final TitanFloat other_value)  |
|TitanFloat sub(final double other_value)  |Subtraction.
|TitanFloat sub(final Ttcn3Float other_value)  |
|TitanFloat sub(final TitanFloat other_value) |
|TitanFloat mul(final double other_value)  |Multiplication.
|TitanFloat mul(final Ttcn3Float other_value)  |
|TitanFloat mul(final TitanFloat other_value)  |
|TitanFloat div(final double other_value)  |Division.
|TitanFloat div(final Ttcn3Float other_value)  |
|TitanFloat div(final TitanFloat other_value)  |
^.^|_Casting operator_
|Double get_value() |Returns the value.
.8+^.^|_Other member functions_
| `boolean is_native()` |is the value native int.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log.
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.


|=================================================================================================

The comparison and arithmetic operators are also available as static functions for that case when the left side is `double` and the right side is `TitanFloat`. Using the value of an unbound variable for anything will cause dynamic test case error.

Other operators (static functions):
[source]
----
TitanFloat add(final double double_value, final TitanFloat other_value);    // Add
TitanFloat sub(final double double_value, final TitanFloat other_value);    // Subtract
TitanFloat mul(final double double_value, final TitanFloat other_value);    // Multiply
TitanFloat div(final double double_value, final TitanFloat other_value);    // Divide
boolean operator_equals(final double doubleValue, final TitanFloat otherValue); // Equal
boolean operator_not_equals(final double doubleValue, final TitanFloat otherValue); // Not equal
boolean is_less_than(final double doubleValue, final TitanFloat otherValue);  // Less than
boolean is_greater_than(final double doubleValue, final TitanFloat otherValue);  // More than
----

=== `Boolean`

The TTCN–3 type `boolean` is implemented in class `TitanBoolean`. +
The class `TitanBoolean` has the following public member functions:

.Public member functions of the class `TitanBoolean`

[cols="20%,80%,20%",,]
|==================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`TitanBoolean()` |Initializes to unbound value.
|`TitanBoolean(final Boolean otherValue)` |Initializes to a given value.
|`TitanBoolean(final TitanBoolean otherValue)` | Copy constructor.
.3+^.^|_Assignment operators_
|`TitanBoolean operator_assign(final boolean otherValue)` |Assigns the given value
|`TitanBoolean operator_assign(final TitanBoolean otherValue)` |and sets the bound flag.
|`TitanBoolean operator_assign(final Base_Type otherValue)` |
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
262 263
|boolean operator_equals(final boolean otherValue) |Returns true if equals
|boolean operator_equals(final TitanBoolean otherValue) |and false otherwise.
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|boolean operator_equals(final Base_Type otherValue) |
|boolean operator_not_equals(final boolean otherValue)|Same as XOR.
|boolean operator_not_equals(final TitanBoolean otherValue) |
.7+^.^|_Logical operators_
|boolean not() |Negation (NOT).
|boolean and(final boolean other_value) |Logical AND.
|boolean and(final TitanBoolean other_value) |
|boolean or(final boolean other_value) |Logical OR.
|boolean or(final TitanBoolean other_value) |
|boolean xor(final boolean other_value) |Exclusive or (XOR).
|boolean xor(final TitanBoolean other_value) |
^.^|_Casting operator_
| Boolean get_value() |Returns the value.
.7+^.^|_Other member functions_
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
Kristof Szabados's avatar
Kristof Szabados committed
281
| `void log()` |Puts the value into log. Like "true" or "false".
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.

|==================================================

The comparison and logical operators are also available as static functions for that case when the left side is `boolean` and the right side is `TitanBoolean`. Using the value of an unbound variable for anything will cause dynamic test case error.

Other operators (static functions):
[source]
----
boolean and(final boolean bool_value, final TitanBoolean other_value); // And
boolean xor(final boolean bool_value, final TitanBoolean other_value);  // Xor
boolean or(final boolean bool_value, final TitanBoolean other_value); // Or
boolean operator_equals(final boolean boolValue, final TitanBoolean otherValue); // Equal
boolean operator_not_equals(final boolean boolValue, final TitanBoolean otherValue);// Not equal
----

=== `Verdicttype`

The TTCN–3 type `verdicttype` is implemented in class `TitanVerdictType`. +
The class `TitanVerdictType` has the following public member functions:

.Public member functions of the class `TitanVerdictType`

[cols="20%,80%,20%",,]
|==================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`TitanVerdictType()` |Initializes to unbound value.
|`TitanVerdictType(final VerdictTypeEnum otherValue)`  |Initializes to a given value.
|`TitanVerdictType(final TitanVerdictType otherValue)`  |Copy constructor.
.3+^.^|_Assignment operators_
|`TitanVerdictType operator_assign(final VerdictTypeEnum otherValue)` |Assigns the given value
|`TitanVerdictType operator_assign(final TitanVerdictType otherValue)`  |and sets the bound flag.
|`TitanVerdictType operator_assign(final Base_Type otherValue)`  |
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
319 320
|boolean operator_equals(final VerdictTypeEnum otherValue) |Returns true if equals
|boolean operator_equals(final TitanVerdictType otherValue) |and false otherwise.
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
|boolean operator_equals(final Base_Type otherValue)  |
|boolean operator_not_equals(final VerdictTypeEnum otherValue)  |
|boolean operator_not_equals(final TitanVerdictType otherValue)  |
^.^|_Casting operator_
|VerdictTypeEnum get_value()  |Returns the value.
.7+^.^|_Other member functions_
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log. Like "pass" or "fail".
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.
|==================================================

The comparison operators are also available as static functions for that case when the left side is `VerdictTypeEnum` and the right side is `TitanVerdictType`. Using the value of an unbound `TitanVerdictType` variable for anything will cause dynamic test case error.

Other operators (static functions):
[source]
----
boolean operator_equals(final VerdictTypeEnum par_value, final TitanVerdictType other_value); // Equal
boolean operator_not_equals(final VerdictTypeEnum par_value, final TitanVerdictType other_value); // Not equal
----

There are the following three static member functions in class `TTCN_Runtime` defined in the Base Library for getting or modifying the local verdict of the current test components:
[source]
----
void setverdict(final TitanVerdictType.VerdictTypeEnum newValue);
void setverdict(final TitanVerdictType newValue);
void setverdict(final TitanVerdictType.VerdictTypeEnum newValue, final String reason);
setverdict(final TitanVerdictType newValue, final String reason);
TitanVerdictType get_verdict();
----

These functions are the Java equivalents of TTCN–3 `setverdict` and `getverdict` operations. Use them only if your Test Port or Java function encounters a low-level failure, but it can continue its normal operation (that is, error recovery is not necessary).

=== `Bitstring`

The equivalent Java class of TTCN–3 type `bitstring` is called `TitanBitString`. The bits of the bit string are stored in an array of ints. In order to reduce the wasted memory space the bits are packed together, so each int contains eight bits. The first int contains the first eight bits of the bit string; the second int contains the bits from the 9th up to the 16th, and so on. The first bit of the bit string is the LSB of the first character; the second bit is the second least significant bit of the first character, and so on. If the length of the bit string is not a multiple of eight, the unused bits of the last character can contain any value. So the length of the bit string must be always given.

The class `TitanBitString` has the following public member functions:

.Public member functions of the class `TitanBitString`

[width="100%",cols="20%,60%,20%"]
|==============================================================================================================================
2+^.^|*Member functions* |*Notes*
.4+^.^|_Constructors_
|`TitanBitString()` |Initializes to unbound value.
|`TitanBitString(final int other_value[], final int nof_bits)` |Initializes from a given length
and  int array.
|`TitanBitString(final TitanBitString otherValue)` |Copy constructor.
|`TitanBitString(final TitanBitString_Element otherValue)` |Initializes from a single bitstring element.
.3+^.^|_Assignment operators_
|`TitanBitString operator_assign(final TitanBitString otherValue)` |Assigns the given value and sets the bound flag.
|`TitanBitString operator_assign(final TitanBitString_Element otherValue)` |Assigns the given single bitstring element.
|`TitanBitString operator_assign(final Base_Type otherValue)` |
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
379 380
|boolean operator_equals(final TitanBitString otherValue) |Returns true if equals
|boolean operator_equals(final TitanBitString_Element otherValue) |and false otherwise.
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
|boolean operator_equals(final Base_Type otherValue) |
|boolean operator_not_equals(final TitanBitString otherValue) |
|boolean operator_not_equals(final TitanBitString_Element otherValue) |
.2+^.^|_Concatenation operator_
|TitanBitString operator_concatenate(final TitanBitString other_value) |Concatenates two bitstrings.
|TitanBitString operator_concatenate(final TitanBitString_Element other_value) |Concatenates a bitstring and a bitstring element.
.4+^.^|_Index operator_
|TitanBitString_Element get_at(final int index_value) |Gives access to the given element. Indexing begins from zero. Index overflow causes dynamic test case error.
|TitanBitString_Element get_at(final TitanInteger index_value) |
|TitanBitString_Element constGet_at(final int index_value) |Gives read-only access to the given element.
|TitanBitString_Element constGet_at(final TitanInteger index_value) |
.7+^.^|_Bitwise operators_
|TitanBitString not4b() | not4b. (bitwise negation)
|TitanBitString and4b(final TitanBitString otherValue) | and4b. (bitwise and)
|TitanBitString and4b(final TitanBitString_Element otherValue) |
|TitanBitString or4b(final TitanBitString otherValue) |or4b. (bitwise or)
|TitanBitString or4b(final TitanBitString_Element otherValue) |
|TitanBitString xor4b(final TitanBitString otherValue) |xor4b. (bitwise xor)
|TitanBitString xor4b(final TitanBitString_Element otherValue) |
.8+^.^|_Shifting and rotating operators_
|TitanBitString shift_left(int shift_count) |Java equivalent of operator
|TitanBitString shift_left(final TitanInteger shift_count) |<<.(shift left)
|TitanBitString shift_right(int shift_count) |Java equivalent of operator
|TitanBitString shift_right(final TitanInteger shift_count) |>>. (shift right)
|TitanBitString rotate_left(int rotate_count) |Java equivalent of operator
Kristof Szabados's avatar
Kristof Szabados committed
406
|TitanBitString rotate_left(final TitanInteger rotate_count) | <@. (rotate left)
407
|TitanBitString rotate_right(int rotate_count) |Java equivalent of operator
Kristof Szabados's avatar
Kristof Szabados committed
408
|TitanBitString rotate_right(final TitanInteger rotate_count) | @>. (rotate right)
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
^.^|_Casting operator_
|int[] get_value() |Returns a pointer to the int array.
.8+^.^|_Other member functions_
|`int lengthof() const` |Returns the length measured in bits.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log. Example: ’100011’B.
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.
|==============================================================================================================================

Using the value of an unbound `TitanBitString` variable for anything will cause dynamic test case error.

==== `Bitstring element`

The Java class `TitanBitString_Element` is the equivalent of the TTCN-3 `bitstring`’s element type (the result of indexing a `bitstring` value). The class does not store the actual bit, only a reference to the original `TitanBitString` object, an index value and a bound flag.

balaskoa's avatar
Typo  
balaskoa committed
428
NOTE: changing the value of the `TitanBitString_Element` (through the assignment operator) changes the referenced bit in the original `bitstring` object.
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490

The class `TitanBitString_Element` has the following public member functions:

.Public member functions of the class `TitanBitString_Element`

[width="100%",cols="20%,80%,20%"]
|========================================================================================================================================================
2+^.^|*Member functions* |*Notes*
|_Constructor_
|`TitanBitString_Element(final boolean par_bound_flag, final TitanBitString par_str_val, final int par_bit_pos)` |Initializes the object with an unbound value or a reference to a bit in an existring TitanBitString object.
.2+^.^|_Assignment operators_
|`TitanBitString_Element operator_assign(final TitanBitString otherValue)` |Sets the referenced bit to the given bitstring of length 1.
|`TitanBitString_Element operator_assign(final TitanBitString_Element otherValue)` |Sets the referenced bit to the given bitstring element.
.4+^.^|_Comparison operators_
|boolean operator_equals(final TitanBitString otherValue) |Comparison with a bitstring or a bitstring element (the value of the referenced bits is compared, not the references and indexes).
|boolean operator_equals(final TitanBitString_Element otherValue) |
|boolean operator_not_equals(final TitanBitString otherValue) |
|boolean operator_not_equals(final TitanBitString_Element otherValue) |
.2+^.^|_Concatenation operator_
|TitanBitString operator_concatenate(final TitanBitString other_value) |Concatenates a bitstring element with a bitstring, or two bitstring elements.
|TitanBitString operator_concatenate(final TitanBitString_Element other_value) |
.7+^.^|_Bitwise operators_
|TitanBitString not4b()| not4b. (bitwise negation)
|TitanBitString and4b(final TitanBitString otherValue) |and4b. (bitwise and)
|TitanBitString and4b(final TitanBitString_Element otherValue)  |
|TitanBitString or4b(final TitanBitString otherValue)  | or4b. (bitwise or)
|TitanBitString or4b(final TitanBitString_Element otherValue)  |
|TitanBitString xor4b(final TitanBitString otherValue) | xor4b. (bitwise xor)
|TitanBitString xor4b(final TitanBitString_Element otherValue) |
.4+^.^|_Other member functions_
|`boolean get_bit()` |Returns the referenced bit.
|`void log()` | Puts the value into log.
Example: '1'B.
|`boolean is_bound()` | Returns whether the value is bound.
| `boolean is_value()` |Returns whether the value is a value.
|========================================================================================================================================================

Using the value of an unbound `TitanBitString_Element` variable for anything will cause dynamic test case error.

=== `Hexstring`

The equivalent Java class of TTCN–3 type `hexstring` is called `TitanHexString`. The hexadecimal digits (nibbles) are stored in an array of unsigned bytes. In order to reduce the wasted memory space two nibbles are packed into one byte. The first byte contains the first two nibbles of the `hexstring`, the second byte contains the third and fourth nibbles, and so on. The hexadecimal digits at odd (first, third, fifth, etc.) positions occupy the lower 4 bits in the characters; the even ones use the upper 4 bits. The length must be always given with the pointer. If the `hexstring` has odd length the unused upper 4 bits of the last character may contain any value.

The class `TitanHexString` has the following public member functions:

.Public member functions of the class `TitanHexString`

[width="100%",cols="20%,60%,20%",options="header",]
|==============================================================================================================================
2+^.^|*Member functions* |*Notes*
.6+^.^|_Constructors_
|`TitanHexString()` |Initializes to unbound value.
|`TitanHexString(final byte otherValue[])` |Initializes from a given byte array.
|`TitanHexString(final TitanHexString otherValue)`|
|`TitanHexString(final TitanHexString_Element otherValue)`|
|`TitanHexString(final byte aValue)`|
|`TitanHexString(final String aValue)`|
.3+^.^|_Assignment operators_
|`TitanHexString operator_assign(final TitanHexString otherValue)` |Assigns the given value
|`TitanHexString operator_assign(final TitanHexString_Element otherValue)` |
|`TitanHexString operator_assign(final Base_Type otherValue)` |
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
491
|boolean operator_equals(final TitanHexString otherValue)  |Returns true if equals and false otherwise.
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
|boolean operator_equals(final TitanHexString_Element otherValue) |
|boolean operator_equals(final Base_Type otherValue) |
|boolean operator_not_equals(final TitanHexString otherValue)  |
|boolean operator_not_equals(final TitanHexString_Element otherValue) |
.2+^.^|_Concatenation operator_
|TitanHexString operator_concatenate(final TitanHexString other_value) |Concatenates two hexstrings.
|TitanHexString operator_concatenate(final TitanHexString_Element other_value) |Concatenates a hexstring and a hexstring element.
.4+^.^|_Index operator_
|TitanHexString_Element get_at(final int index_value) |Gives access to the given element. Indexing begins from zero. Index overflow causes dynamic test case error.
|TitanHexString_Element get_at(final TitanInteger index_value) |
|TitanHexString_Element constGet_at(final int index_value) |
|TitanHexString_Element constGet_at(final TitanInteger index_value) |
.7+^.^|_Bitwise operators_
|TitanHexString not4b()  | not4b. (bitwise negation)
|TitanHexString and4b(final TitanHexString otherValue)  |and4b. (bitwise and)
|TitanHexString and4b(final TitanHexString_Element otherValue) |
|TitanHexString or4b(final TitanHexString otherValue) |or4b. (bitwise or)
|TitanHexString or4b(final TitanHexString_Element otherValue)  |
|TitanHexString xor4b(final TitanHexString otherValue)  |xor4b. (bitwise xor)
|HTitanHexString xor4b(final TitanHexString_Element otherValue)  |
.8+^.^|_Shifting and rotating operators_
|TitanHexString shift_left(int shift_count)  |Java equivalent of operator
|TitanHexString shift_left(final TitanInteger shift_count)  |<<.(shift left)
|TitanHexString shift_right(int shift_count) |Java equivalent of operator
|TitanHexString shift_right(final TitanInteger shift_count) |>>. (shift right)
|TitanHexString rotate_left(int rotate_count)  |Java equivalent of operator
Kristof Szabados's avatar
Kristof Szabados committed
518
|TitanHexString rotate_left(final TitanInteger rotate_count)  |<@. (rotate left)
519
|TitanHexString rotate_right(int rotateCount)|Javaequivalent of operator
Kristof Szabados's avatar
Kristof Szabados committed
520
|TitanHexString rotate_right(final TitanInteger rotateCount) |@>. (rotate right)
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
^.^|_Casting operator_
|byte[] get_value() |Returns a pointer to the character array. The pointer might be NULL if the length is 0.
.4+^.^|_Other member functions_
|`int lengthof() const` |Returns the length measured in bits.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log. Example: ’5A7’H.
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.
|==============================================================================================================================

Using the value of an unbound `TitanHexString` variable for anything will cause a dynamic test case error.

==== `Hexstring` element

The Java class `TitanHexString_Element` is the equivalent of the TTCN-3 `hexstring`’s element type (the result of indexing a `hexstring` value). The class does not store the actual hexadecimal digit (nibble), only a reference to the original TitanHexString object, an index value and a bound flag.

balaskoa's avatar
Typo  
balaskoa committed
540
NOTE: changing the value of the `TitanHexString_Element` (through the assignment operator) changes the referenced nibble in the original `hexstring` object.
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599

The class `TitanHexString_Element` has the following public member functions:

.Public member functions of the class `TitanHexString_Element`

[width="100%",cols="20%,60%,20%",options="",]
|===========================================================================================================================================================
2+^.^|*Member functions* |*Notes*
^.^|_Constructor_
| `TitanHexString_Element(final boolean par_bound_flag, final TitanHexString par_str_val, final int par_nibble_pos)` |Initializes the object with an unbound value or a reference to a nibble in an existring TitanHexString object.
.2+^.^|_Assignment operators_
|`TitanHexString_Element operator_assign(final TitanHexString otherValue)` |Sets the referenced nibble to the given hexstring of length 1.
|`TitanHexString_Element operator_assign(final TitanHexString_Element otherValue)` | Sets the referenced nibble to the given hexstring element.
.4+^.^|_Comparison operators_
|boolean operator_equals(final TitanHexString otherValue) |Comparison with a hexstring or a hexstring element (the value of the referenced nibbles is compared, not the references and indexes).
|boolean operator_equals(final TitanHexString_Element otherValue)  |
|boolean operator_not_equals(final TitanHexString otherValue) |
|boolean operator_not_equals(final TitanHexString_Element otherValue)  |
.2+^.^|_Concatenation operator_
|TitanHexString operator_concatenate(final TitanHexString other_value) |Concatenates a hexstring element with a hexstring, or two hexstring elements.
|TitanHexString operator_concatenate(final TitanHexString_Element other_value) |
.7+^.^|_Bitwise operators_
|TitanHexString not4b()  |Java equivalent of operator not4b. (bitwise negation)
|TitanHexString and4b(final TitanHexString other_value) |and4b. (bitwise and)
|TitanHexString and4b(final TitanHexString_Element other_value) |
|TitanHexString or4b(final TitanHexString other_value)  |or4b. (bitwise or)
|TitanHexString or4b(final TitanHexString_Element other_value)  |
|TitanHexString xor4b(final TitanHexString other_value) |xor4b. (bitwise xor)
|TitanHexString xor4b(final TitanHexString_Element other_value) |
.4+^.^|_Other member functions_
|`char get_nibble()` |Returns the referenced nibble (stored in the lower 4 bits of the returned character).
|`void log()` |Puts the value into log. Example: '8'H.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
|===========================================================================================================================================================

Using the value of an unbound `TitanHexString_Element` variable for anything will cause dynamic test case error.

=== `Octetstring`

The equivalent Java class of TTCN–3 type `octetstring` is called `TitanOctetString`. The octets are stored in an array of unsigned characters. Each character contains one octet; the first character is the first octet of the string. The length of the octet string must be always given.

The class `TitanOctetString` has the following public member functions:

.Public member functions of the class `TitanOctetString`

[width="100%",cols="20%,60%,20%",options="header",]
|==============================================================================================================================
2+^.^|*Member functions* |*Notes*
.4+^.^|_Constructors_
|`TitanOctetString()` |Initializes to unbound value.
|`TitanOctetString(final char otherValue[])` |Initializes from a given character array.
|`TitanOctetString(final TitanOctetString otherValue)` |Copy constructor.
|`TitanOctetString(final TitanOctetString_Element otherValue)` |Initializes from a single octetstring element.
.3+^.^|_Assignment operators_
|`TitanOctetString operator_assign(final TitanOctetString otherValue)` |Assigns the given value and sets the bound flag.
|`TitanOctetString operator_assign(final TitanOctetString_Element otherValue)` |Assigns the given octetstring element.
|`TitanOctetString operator_assign(final Base_Type otherValue)` |
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
600 601
| boolean operator_equals(final TitanOctetString otherValue)  |Returns true if equals
| boolean operator_equals(final TitanOctetString_Element otherValue)  |and false otherwise.
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
| boolean operator_equals(final Base_Type otherValue)  |
| boolean operator_not_equals(final TitanOctetString otherValue)  |
| boolean operator_not_equals(final TitanOctetString_Element otherValue)  |
.2+^.^|_Concatenation operator_
|TitanOctetString operator_concatenate(final TitanOctetString other_value) |Concatenates two octetstrings.
|TitanOctetString operator_concatenate(final TitanOctetString_Element other_value) |Concatenates an octetstring and an octetstring element.
.4+^.^|_Index operator_
|TitanOctetString_Element get_at(final int index_value) |Gives access to the given element. Indexing begins from zero. Index overflow causes dynamic test case error.
|TitanOctetString_Element get_at(final TitanInteger index_value) |
|TitanOctetString_Element constGet_at(final int index_value) |Gives read-only access to the given element.
|TitanOctetString_Element constGet_at(final TitanInteger index_value) |
.7+^.^|_Bitwise operators_
|TitanOctetString not4b()  | not4b.(bitwise negation)
|TitanOctetString and4b(final TitanOctetString otherValue) | and4b.(bitwise and)
|TitanOctetString and4b(final TitanOctetString_Element otherValue) |
|TitanOctetString or4b(final TitanOctetString otherValue)  | or4b.(bitwise or)
|TitanOctetString or4b(final TitanOctetString_Element otherValue) |
|TitanOctetString xor4b(final TitanOctetString otherValue) | xor4b. (bitwise xor)
|TitanOctetString xor4b(final TitanOctetString_Element otherValue) |
.8+^.^|_Shifting and rotating operators_
|TitanOctetString shift_left(final int shift_count) | operator <<.
|TitanOctetString shift_left(final TitanInteger shift_count) |(shift left)
|TitanOctetString shift_right(final int shift_count)  |operator >>.
|TitanOctetString shift_right(final TitanInteger shift_count)  |(shift right)
Kristof Szabados's avatar
Kristof Szabados committed
626
|TitanOctetString rotate_left(final int rotate_count)  |operator <@.
627
|TitanOctetString rotate_left(final TitanInteger rotate_count)  |(rotate left)
Kristof Szabados's avatar
Kristof Szabados committed
628
|TitanOctetString rotate_right(final int rotate_count) |operator @>.
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
|TitanOctetString rotate_right(final TitanInteger rotate_count)  |(rotate right)
^.^|_Casting operator_
|char[] get_value() |Returns a pointer to the character array. The pointer might be NULL if the length is 0.
.8+^.^|_Other member functions_
|`int lengthof() const` |Returns the length measured in bits.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log. Like ’073CF0’O.
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.
|==============================================================================================================================

Using the value of an unbound `TitanOctetString` variable for anything will cause dynamic test case error.

==== `Octetstring` element

The Java class `TitanOctetString_Element` is the equivalent of the TTCN-3 `octetstring`’s element type (the result of indexing an `octetstring` value). The class does not store the actual octet, only a reference to the original TitanOctetString object, an index value and a bound flag.

balaskoa's avatar
Typo  
balaskoa committed
649
NOTE: changing the value of the TitanOctetString_Element (through the assignment operator) changes the referenced octet in the original `octetstring` object.
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717

The class `TitanOctetString_Element` has the following public member functions:

.Public member functions of the class `TitanOctetString_Element`

[width="100%",cols="20%,60%,20%",options="header",]
|================================================================================================================================================================
2+^.^|*Member functions* |*Notes*
^.^|_Constructor_
|`TitanOctetString_Element(final boolean par_bound_flag, final TitanOctetString par_str_val, final int par_nibble_pos)` |Initializes the object with an unbound value or a reference to an octet in an existing TitanOctetString object.
.2+^.^|_Assignment operators_
|`TitanOctetString_Element operator_assign(final TitanOctetString otherValue)` |Sets the referenced octet to the given octetstring of length 1.
|`TitanOctetString_Element operator_assign(final TitanOctetString_Element otherValue)` |Sets the referenced octet to the given octetstring element.
.4+^.^|_Comparison operators_
|TitanOctetString_Element operator_equals(final TitanOctetString otherValue) |Comparison with an octetstring or an octetstring element (the value of the referenced octets is compared, not the references and indexes).
|TitanOctetString_Element operator_equals(final TitanOctetString_Element otherValue)  |
|boolean operator_not_equals(final TitanOctetString otherValue) |
|boolean operator_not_equals(final TitanOctetString_Element otherValue)  |
.2+^.^|_Concatenation operator_
| TitanOctetString operator_concatenate(final TitanOctetString other_value) |Concatenates an octetstring element with an octetstring, or two octetstring elements.
| TitanOctetString operator_concatenate(final TitanOctetString_Element other_value) |
.7+^.^|_Bitwise operators_
|TitanOctetString not4b() | bitwise negation
|TitanOctetString and4b(final TitanOctetString other_value) |and4b. (bitwise and)
|TitanOctetString and4b(final TitanOctetString_Element other_value)  |
|TitanOctetString or4b(final TitanOctetString other_value)  | or4b. (bitwise or)
|TitanOctetString or4b(final TitanOctetString_Element other_value)  |
|TitanOctetString xor4b(final TitanOctetString other_value) |xor4b. (bitwise xor)
|TitanOctetString xor4b(final TitanOctetString_Element other_value) |
.4+^.^|_Other member functions_
|`char get_nibble()` |Returns the referenced octet.
|`void log()` |Puts the value into log. Example: '3C'O.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
|================================================================================================================================================================

Using the value of an unbound `TitanOctetString_Element` variable for anything will cause dynamic test case error.

=== `Char`

The `char` type, which has been removed from the TTCN–3 standard, is no longer supported by the run-time environment. The compiler substitutes all occurrences of `char` type with type `charstring` automatically.

[[Charstring]]
=== `Charstring`

The equivalent Java class of TTCN–3 type `charstring` is called `TitanCharString`. The characters are stored in a StringBuilder..

The class `TitanCharString` has the following public member functions:

.Public member functions of the class `TitanCharString`

[width="100%",cols="20%,60%,20%",,]
|==============================================================================================================================
2+^.^|*Member functions* |*Notes*
.6+^.^|_Constructors_
|`TitanCharString()`|Initializes to unbound value.
|`TitanCharString(final String otherValue)`|Initializes from a String.
|`TitanCharString(final StringBuilder otherValue)`| Initializes from the StringBuilder.
|`TitanCharString(final TitanCharString otherValue)`|Copy constructor.
|`TitanCharString(final TitanCharString_Element otherValue)`|Initializes from a charstring element.
|`TitanCharString(final TitanUniversalCharString otherValue)`| Initializs from the universal charstring.
.5+^.^|_Assignment operators_
|`TitanCharString operator_assign(final String otherValue)`|Assigns the given value and sets the bound flag.
|`TitanCharString operator_assign(final TitanCharString otherValue)`|
|`TitanCharString operator_assign(final Base_Type otherValue)`|
|`TitanCharString operator_assign(final TitanCharString_Element otherValue)`|
|`TitanCharString operator_assign(final TitanUniversalCharString otherValue)`|
.9+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
718
|boolean operator_equals(final TitanCharString otherValue) |Returns true if equals and false otherwise.
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
|boolean operator_equals(final TitanUniversalCharString otherValue) |
|boolean operator_equals(final Base_Type otherValue) |
|boolean operator_equals(final String otherValue) |
|boolean operator_equals(final TitanCharString_Element otherValue) |
|boolean operator_equals(final TitanUniversalCharString_Element otherValue)|
|boolean operator_not_equals(final TitanCharString otherValue) |
|boolean operator_not_equals(final TitanCharString_Element otherValue)|
|boolean operator_not_equals(final String otherValue) |
.7+^.^|_Concatenation operator_
|TitanCharString operator_concatenate(final TitanCharString other_value) |Concatenates two charstrings.
|TitanCharString operator_concatenate(final String other_value) |
|TitanCharString operator_concatenate(final TitanCharString_Element other_value) |
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString other_value) |Concatenates with a universal charstring.
|TitanCharString append(final String aOtherValue) |Appends a String.
|TitanCharString append(final TitanCharString_Element aOtherValue) |
|TitanCharString append(final TitanCharString aOtherValue) |Appends a charstring.
.4+^.^|_Index operator_
|TitanCharString_Element get_at(final int index_value) |Gives access to the given element. Indexing begins from zero. Index overflow causes dynamic test case error.
|TitanCharString_Element get_at(final TitanInteger index_value) |
|TitanCharString_Element constGet_at(final int index_value) |Gives read-only access to the given element.
|TitanCharString_Element constGet_at(final TitanInteger index_value) |
.4+^.^|_Rotating operators_
Kristof Szabados's avatar
Kristof Szabados committed
741
|TitanCharString rotate_left(final int rotate_count) |Java equivalent of operator <@.(rotate left)
742
|TitanCharString rotate_left(final TitanInteger rotate_count) |
Kristof Szabados's avatar
Kristof Szabados committed
743
|TitanCharString rotate_right(final int rotate_count)  | @>. (rotate right)
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
|TitanCharString rotate_right(final TitanInteger rotate_count) |
^.^|_Casting operator_
|StringBuilder get_value() |Returns the StringBuilder.
.8+^.^|_Other member functions_
|`int lengthof() const` |Returns the length measured in bits.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log. Like "abc".
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.

|==============================================================================================================================

The comparison, concatenation and rotating operators are also available as static functions for that case when the left side is `String` and the right side is `TitanCharString`.

The log() member function uses single character output for regular characters, but special characters (such as the quotation mark, backslash or newline characters) are printed using the escape sequences of the C language. Non-printable control characters are printed in TTCN–3 quadruple notation, where the first three octets are always zero. The concatenation operator (`&`) is used between the fragments when necessary. Note that the output does not always conform to TTCN–3 Core Language syntax, but it is always recognized by both our compiler and the configuration file parser.

Using the value of an unbound `TitanCharString` variable for anything will cause dynamic test case error.

Other operators (static functions):
[source]
----
boolean operator_equals(final String stringValue, final TitanCharString otherValue);            // Equal
boolean operator_equals(final String stringValue, final TitanCharString_Element otherValue);    // Equal
boolean operator_not_equals(final String stringValue, final TitanCharString otherValue);            // Not equal
boolean operator_not_equals(final String stringValue, final TitanCharString_Element otherValue);    // Not equal
TitanCharString operator_concatenate(final String stringValue, final TitanCharString other_value);          // Concatenation
TitanCharString operator_concatenate(final String stringValue, final TitanCharString_Element other_value);  // Concatenation
----

==== `Charstring` element

The Java class `TitanCharString_Element` is the equivalent of the TTCN-3 `charstring`’s element type (the result of indexing a `charstring` value). The class does not store the actual character, only a reference to the original TitanCharString object, an index value and a bound flag.

balaskoa's avatar
Typo  
balaskoa committed
780
NOTE: changing the value of the `TitanCharString_Element` (through the assignment operator) changes the referenced character in the original `charstring` object.
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840

The class `TitanCharString_Element` has the following public member functions:

.Public member functions of the class `TitanCharString_Element`

[width="100%",cols="20%,60%,20%",options="",]
|================================================================================================================================================================================================================================================================================
2+^.^|*Member functions* |*Notes*
^.^|_Constructor_
|`TitanCharString_Element(final boolean par_bound_flag, final TitanCharString par_str_val, final int par_char_pos)` |Initializes the object with an unbound value or a reference to a character in an existing TitanCharString object.
.3+^.^|_Assignment operators_
|`TitanCharString_Element operator_assign(final String otherValue)` |Sets the referenced character to the given String of length 1.
|`TitanCharString_Element operator_assign(final TitanCharString otherValue)` |Sets the referenced character to the given charstring of length 1.
|`TitanCharString_Element operator_assign(final TitanCharString_Element otherValue)` |Sets the referenced character to the given charstring element.
.8+^.^|_Comparison operators_
|boolean operator_equals(final String otherValue) |Comparison with a String.
|boolean operator_equals(final TitanCharString otherValue) |
|boolean operator_equals(final TitanCharString_Element otherValue)  |
|boolean operator_equals(final TitanUniversalCharString otherValue) |
|boolean operator_equals(final TitanUniversalCharString_Element otherValue) |
|boolean operator_not_equals(final String otherValue)  |
|boolean operator_not_equals(final TitanUniversalCharString otherValue) |
|boolean operator_not_equals(final TitanUniversalCharString_Element otherValue)  |
.5+^.^|_Concatenation operator_
|TitanCharString operator_concatenate(final String other_value) |Concatenates this object with a String.
|TitanCharString operator_concatenate(final TitanCharString other_value) |
|TitanCharString operator_concatenate(final TitanCharString_Element other_value) |
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString other_value) |
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString_Element other_value)  |
.3+^.^|_Other member functions_
|`char get_char()` |Returns the referenced character.
|`void log()` |Puts the value into log. Example: “a”.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.

|================================================================================================================================================================================================================================================================================

Using the value of an unbound `TitanCharString_Element` variable for anything will cause dynamic test case error.

=== `Universal char`

This obsolete TTCN–3 type is converted automatically to `universal charstring` in the parser.

=== `Universal charstring`

Each character of a `universal charstring` value is represented in the following C structure defined in the Base Library:
[source]
----
public class TitanUniversalChar {
	private char uc_group;
	private char uc_plane;
	private char uc_row;
	private char uc_cell;
  ...
----

The four components of the quadruple (that is, group, plane, row and cell) are stored in fields `uc_group`, `uc_plane`, `uc_row` and `uc_cell`, respectively. All fields are 8bit unsigned numeric values with the possible value range 0 .. 255.

In case of single-octet characters, which can be also given in TTCN–3 charstring notation (between quotation marks), the fields `uc_group`, `uc_plane`, `uc_row` are set to zero. If tuple notation was used for an ASN.1 string value fields `uc_row` and `uc_cell` carry the tuple and the others are set to zero.

Kristof Szabados's avatar
Kristof Szabados committed
841
Except when performing encoding or decoding, the run-time environment does not check whether the quadruples used in the following API represent valid character positions according to <<14-references.adoc#_8,[8]>>. Moreover, if ASN.1 multi-octet character string values are used, it is not verified whether the elements of such strings are permitted characters of the corresponding string type.
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876

The Java equivalent of TTCN–3 type `universal charstring` is implemented in class `TitanUniversalCharString`. The characters of the string are stored in an array of structure `TitanUniversalChar`. The array returned by the casting operator is not terminated with a special character, thus, the length of the string must be always considered when doing operations with the array. The length of the string, which can be obtained by using member function `lengthof()`, is measured in characters (quadruples) and not bytes.

For the more convenient usage the strings containing only single-octet characters can also be used with class `TitanUniversalCharString`. Therefore some polymorphic member functions and operators have variants that take `String` as argument. In these member functions the characters of the String are implicitly converted to quadruples with group, plane and row fields set to zero.

The class `TitanUniversalCharString` has the following public member functions:

.Public member functions of the class `TitanUniversalCharString`

[width="100%",cols="20%,60%,20%",options="",]
|==============================================================================================================================
2+^.^|*Member functions* |*Notes*
.7+^.^|_Constructors_
|`TitanUniversalCharString()`|Initializes to unbound value.
|`TitanUniversalCharString(final char uc_group, final char uc_plane, final char uc_row,  final char uc_cell)`| Constructs a string containing one character formed from the given quadruple.
|`TitanUniversalCharString(final TitanUniversalChar otherValue)`| Constructs a string containing the given single character.
|`TitanUniversalCharString(final List<TitanUniversalChar> otherValue)`| Constructs a string from an array by taking the given number of single-octet characters.
|`TitanUniversalCharString(final TitanUniversalChar[] otherValue)`|
|`TitanUniversalCharString(final String otherValue)`|
|`TitanUniversalCharString(final StringBuilder otherValue)`|
.4+^.^|_Constructors_
|`TitanUniversalCharString(final TitanCharString otherValue)`| Constructs a universal charstring from a charstring value.
|`TitanUniversalCharString(final TitanCharString_Element otherValue)`| Constructs a string containing the given singe charstring element.
|`TitanUniversalCharString(final TitanUniversalCharString otherValue)`| Copy constructor.
|`TitanUniversalCharString(final TitanUniversalCharString_Element otherValue)`| Constructs a string containing the given singe universal charstring element.
.8+^.^|_Assignment operators_
|`TitanUniversalCharString operator_assign(final TitanUniversalCharString otherValue)`  |Assigns another string.
|`TitanUniversalCharString operator_assign(final TitanUniversalChar otherValue)` |Assigns a single character.
|`TitanUniversalCharString operator_assign(final char[] otherValue)` |Assigns an array single-octet characters.
|`TitanUniversalCharString operator_assign(final String otherValue)`|
|`TitanUniversalCharString operator_assign(final TitanCharString otherValue)` |Assigns a charstring.
|`TitanUniversalCharString operator_assign(final TitanCharString_Element otherValue)` |Assigns a single charstring element.
|`TitanUniversalCharString operator_assign(final TitanUniversalCharString_Element otherValue)` |Assigns a single universal charstring element.
|`TitanUniversalCharString operator_assign(final Base_Type otherValue)`|
.7+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
877
|boolean operator_equals(final TitanUniversalCharString otherValue)  |Returns true if the strings are identical or false otherwise.
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
|boolean operator_equals(final TitanUniversalChar otherValue)  |Compares to a single character.
|boolean operator_equals(final String otherValue) |Compares to a String.
|boolean operator_equals(final TitanCharString otherValue) |Compares to a charstring.
|boolean operator_equals(final TitanCharString_Element otherValue) |Compares to a charstring element.
|boolean operator_equals(final TitanUniversalCharString_Element otherValue)|Compares to a universal charstring element.
|boolean operator_equals(final Base_Type otherValue)|
.7+^.^|_Comparison operators_
|boolean operator_not_equals(final TitanUniversalCharString otherValue)  |
|boolean operator_not_equals(final TitanUniversalChar otherValue) |
|boolean operator_not_equals(final String otherValue)  |
|boolean operator_not_equals(final TitanCharString otherValue) |
|boolean operator_not_equals(final TitanCharString_Element otherValue) |
|boolean operator_not_equals(final TitanUniversalCharString_Element otherValue) |
|boolean operator_not_equals(final Base_Type otherValue)|
.6+^.^|_Concatenation operator_
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString other_value) |Concatenates two strings.
|TitanUniversalCharString operator_concatenate(final TitanUniversalChar other_value)  |Concatenates a single character.
|TitanUniversalCharString operator_concatenate(final String other_value)  |Concatenates a single-octet string.
|TitanUniversalCharString operator_concatenate(final TitanCharString other_value) |Concatenates a charstring.
|TitanUniversalCharString operator_concatenate(final TitanCharString_Element other_value) |Concatenates a charstring element.
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString_Element other_value)  |Concatenates a universal charstring element.
.4+^.^|_Index operator_
|TitanUniversalCharString_Element get_at(final int index_value)|Gives access to the given element. Indexing begins from zero. Index overflow causes dynamic test case error.
|TitanUniversalCharString_Element get_at(final TitanInteger index_value) |
|TitanUniversalCharString_Element constGet_at(final int index_value) |Gives read-only access to the given element.
|TitanUniversalCharString_Element constGet_at(final TitanInteger index_value) |
.4+^.^|_Rotating operators_
Kristof Szabados's avatar
Kristof Szabados committed
905
|TitanUniversalCharString rotate_left(final int rotate_count) | <@(rotate left).
906
|TitanUniversalCharString rotate_left(final TitanInteger rotate_count) |
Kristof Szabados's avatar
Kristof Szabados committed
907
|TitanUniversalCharString rotate_right(final int rotate_count) | @>(rotate right).
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
|TitanUniversalCharString rotate_right(final TitanInteger rotate_count) |
^.^|_Casting operator_
|List<TitanUniversalChar> get_value() |Returns a pointer to the array of characters. There is no terminator character at the end.
.7+^.^|_UTF-8 encoding and decoding_
|void encode_utf8(final TTCN_Buffer buf) |Appends the UTF-8 representation of the string to the given buffer
|void encode_utf8(final TTCN_Buffer buf, final boolean addBOM) |
|void decode_utf8(final char[] valueStr, final CharCoding code, final boolean checkBOM)|
|void encode_utf16(final TTCN_Buffer buf, final CharCoding expected_coding)|
|void decode_utf16(final int n_octets, final char[] octets_ptr, final CharCoding expected_coding)|
|void encode_utf32(final TTCN_Buffer buf, final CharCoding expected_coding)|
|void decode_utf32(final int n_octets, final char[] octets_ptr, final CharCoding expected_coding) |
.8+^.^|_Other member functions_
|`int lengthof() const` |Returns the length measured in characters.
| `boolean is_bound()` |Returns whether the value is bound.
| `boolean is_present()` |Returns whether the value is present.
| `boolean is_value()` |Returns whether the value is a value.
| `void log()` |Puts the value into log. See below.
| `void clean_up()` |Deletes the value, setting it to unbound.
| `void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |encodes the value.
| `void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)` |decodes the value.
|==============================================================================================================================

The comparison and concatenation operators are also available as static functions for that case when the left operand is a single-octet string (`String`) or a single character (`TitanUniversalChar`) and the right side is `TitanUniversalCharString` value. Using the value of an unbound `TitanUniversalCharString` variable for anything causes dynamic test case error.

The `TitanUniversalCharString` variable used with the `decode_utf8()` method must be newly constructed (unbound) or `clean_up()` must have been called, otherwise a memory leak will occur.

The logged printout of universal charstring values is compatible with the TTCN–3 notation for such strings. The format to be used depends on the contents of the string. Each character (quadruple) is classified whether it is directly printable or not. The string is fragmented based on this classification. Each fragment consists of either a single non-printable character or a maximal length contiguous sequence of printable characters. The fragments are logged one after another separated by an `&` character (concatenation operator). The printable fragments use the normal charstring notation; the non-printable characters are logged in the TTCN–3 quadruple notation. An empty universal charstring value is represented by a pair of quotation marks (like in case of empty charstring values).

An example printout in the log can be the following. The string consists of two fragments of printable characters and a non-printable quadruple, which stands for Hungarian letter "ű":
[source, subs="+quotes"]
"Character " & char(0, 0, 1, 113) & " is a letter of Hungarian alphabet"

Other operators (static functions):
[source]
----
boolean operator_equals(final TitanUniversalChar left_value, final TitanUniversalChar right_value); //Equal
boolean operator_equals(final TitanUniversalChar ucharValue, final TitanUniversalCharString otherValue);  // Equal
boolean operator_equals(final String otherValue, final TitanUniversalCharString rightValue));  // Equal
boolean operator_not_equals(final TitanUniversalChar left_value, final TitanUniversalChar right_value); //Not equal
boolean operator_not_equals(final TitanUniversalChar ucharValue, final TitanUniversalCharString otherValue);  // Not equal
boolean operator_not_equals(final String otherValue, final TitanUniversalCharString rightValue));  // Not equal
TitanUniversalCharString operator_concatenate(final TitanUniversalChar ucharValue, final TitanUniversalCharString other_value);  // Concatenation
TitanUniversalCharString operator_concatenate(final String stringValue, final TitanUniversalCharString other_value); // Concatenation
----

==== `Universal charstring` element

The Java class `TitanUniversalCharString_Element` is the equivalent of the TTCN-3 `universal charstring`’s element type (the result of indexing a `universal charstring` value). The class does not store the actual character, only a reference to the original `TitanUniversalCharString` object, an index value and a bound flag.

balaskoa's avatar
Typo  
balaskoa committed
957
NOTE: changing the value of the `TitanUniversalCharString_Element` (through the assignment operator) changes the referenced character in the original `universal charstring` object.
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022

The class `TitanUniversalCharString_Element` has the following public member functions:

.Public member functions of the class `TitanUniversalCharString_Element`

[width="100%",cols="20%,60%,20%",options="",]
|=======================================================================================================================================================================================================================================================================================================
2+^.^|*Member functions* |*Notes*
^.^|_Constructor_
|`TitanUniversalCharString_Element(final boolean par_bound_flag, final TitanUniversalCharString par_str_val, final int par_char_pos)` |Initializes the object with an unbound value or a reference to a character in an existing TitanUniversalCharString object.
.6+^.^|_Assignment operators_
|`TitanUniversalCharString_Element operator_assign(final TitanUniversalChar otherValue)` |Sets the referenced character to the given universal character.
|`TitanUniversalCharString_Element operator_assign(final String otherValue)` |
|`TitanUniversalCharString_Element operator_assign(final TitanCharString otherValue)` |
|`TitanUniversalCharString_Element operator_assign(final TitanCharString_Element otherValue)` |
|`TitanUniversalCharString_Element operator_assign(final TitanUniversalCharString otherValue)` |
|`TitanUniversalCharString_Element operator_assign(final TitanUniversalCharString_Element otherValue)` |
.6+^.^|_Comparison operators_
|boolean operator_equals(final TitanUniversalChar otherValue) |Comparison with a universal character.
|boolean operator_equals(final String otherValue) |
|boolean operator_equals(final TitanCharString otherValue) |
|boolean operator_equals(final TitanCharString_Element otherValue)  |
|boolean operator_equals(final TitanUniversalCharString otherValue) |
|boolean operator_equals(final TitanUniversalCharString_Element otherValue) |
.6+^.^|_Comparison operators_
|boolean operator_not_equals(final TitanUniversalChar otherValue) |
|boolean operator_not_equals(final String otherValue) |
|boolean operator_not_equals(final TitanCharString otherValue) |
|boolean operator_not_equals(final TitanCharString_Element otherValue)  |
|boolean operator_not_equals(final TitanUniversalCharString otherValue) |
|boolean operator_not_equals(final TitanUniversalCharString_Element otherValue) |
.6+^.^|_Concatenation operator_
|TitanUniversalCharString operator_concatenate(final TitanUniversalChar other_value) |Concatenates this object with a universal character.
|TitanUniversalCharString operator_concatenate(final String other_value) |
|TitanUniversalCharString operator_concatenate(final TitanCharString other_value) |
|TitanUniversalCharString operator_concatenate(final TitanCharString_Element other_value) |
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString other_value) |
|TitanUniversalCharString operator_concatenate(final TitanUniversalCharString_Element other_value)  |
.5+^.^|_Other member functions_
|`TitanUniversalChar get_char()` |Returns the referenced character.
|`void log()` |Puts the value into log. Example: “a” or char(0, 0, 1, 113).
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_present()` |Returns whether the value is present.
|`boolean is_value()` |Returns whether the value is a value.
|=======================================================================================================================================================================================================================================================================================================

Using the value of an unbound `TitanUniversalCharString_Element` variable for anything will cause dynamic test case error.

=== Object Identifier Type

The object identifier type of TTCN–3 (`objid`) is implemented in class TitanObjectid. In the run-time environment the components of object identifier values are represented in NumberForm, that is, in integer values. The values of components are stored in an array with a given length. The type of the components is specified with a `TitanInteger`. Class `TitanObjectid` has the following member functions.

.Public member functions of the class `TitanObjectid`

[width="100%",cols="20%,60%,20%",options="header",]
|=====================================================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`TitanObjectid()` |Initializes to unbound value.
|`TitanObjectid(final int init_n_components, final TitanInteger... values)` |Initializes the number of components to n_components. The components themselves shall be given as additional integer arguments after each other, starting with the first one.
|TitanObjectid(final TitanObjectid otherValue) |Copy constructor.
.2+^.^|_Assignment operator_
|`TitanObjectid operator_assign(final TitanObjectid otherValue)` |Assigns the given value and sets the bound flag.
|`Base_Type operator_assign(final Base_Type otherValue)`|
.3+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1023
|boolean operator_equals(final TitanObjectid otherValue) |Returns true if the two values are equal and false otherwise.
1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077
|boolean operator_equals(final Base_Type otherValue)|
|boolean operator_not_equals(final TitanObjectid otherValue) |
.4+^.^|_Indexing operators_
|TitanInteger get_at(final int index_value)  |Returns a reference to the _i th_ component.
|TitanInteger get_at(final TitanInteger index_value)|
|TitanInteger constGet_at(final int index_value) |Returns a read-only reference to the i th component.
|TitanInteger constGet_at(final TitanInteger index_value)|
.5+^.^|_Other member functions_
|`TitanInteger lengthof()` |Returns the number of components.
|`void log()` |Puts the value into log in NumberForm. Like this: “objid 0 4 0 ”.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_present()` |Returns whether the value is present.
|`void clean_up()` |Deletes the value, setting it to unbound.

|=====================================================================================

NOTE: The constructor with variable number of arguments is useful in situations when the number of components is constant and known at compile time.

Using the value of an unbound `TitanObjectid` variable for anything will cause dynamic test case error.

=== Component References

TTCN–3 variables of component types are used for storing component references to PTCs. The internal representation of component references are test tool dependent, our test executor handles them as small integer numbers.

All TTCN–3 component types are mapped to the same Java class, which is called TitanComponent.

There are some predefined constants of component references in TTCN–3. These are public static final members of the TitanComponent class defined in the following way:

.Predefined component references

[cols=",,",options="header",]
|===================================================
|TTCN–3 constant |TitanComponent member name |Numeric value
|null |NULL |COMPREF 0
|mtc |MTC |COMPREF 1
|system |SYSTEM |COMPREF 2
|===================================================

The class `TitanComponent` has the following public member functions:

.Public member functions of the class `TitanComponent`

[width="100%",cols="20%,60%,20%",options="",]
|===========================================================================================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`TitanComponent()` |Initializes to unbound value.
|`TitanComponent(final int otherValue)` |Initializes to a given value.
|`TitanComponent(final TitanComponent otherValue)` |Copy constructor.
.3+^.^|_Assignment_ _operators_
|`TitanComponent operator_assign(final int otherValue)`|Assigns the given value
|`TitanComponent operator_assign(final TitanComponent otherValue)`|and sets the bound flag.
|`TitanComponent operator_assign(final Base_Type otherValue)`|
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1078 1079
|boolean operator_equals(final int otherValue)  |Returns true if equals
|boolean operator_equals(final TitanComponent otherValue) |and false otherwise.
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141
|boolean operator_equals(final Base_Type otherValue)|
|boolean operator_not_equals(final int otherValue)  |
|boolean operator_not_equals(final TitanComponent otherValue)  |
^.^|_Casting operator_
|int get_component() |Returns the value.
.5+^.^|Other member functions
|`void log()` |Puts the value into log in decimal form or in symbolic format for special constants. Like 3 or mtc.
|`boolean is_present()` |Returns whether the value is present.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
|`void clean_up()` |Deletes the value, setting it to unbound.

|===========================================================================================================================

Component references are managed by MC. All new test components are given a unique reference that was never used in the test campaign before (not even in a previous test case). The new numbers are increasing monotonously. The reference of the firstly created component is 3; the next one will be 4, and so on.

Using the value of an unbound component reference for anything will cause dynamic test case error.

Other operators (static functions):
[source]
----
boolean operator_equals(final int left_value, final TitanComponent right_value); // Equal
boolean operator_not_equals(final int left_value, final TitanComponent right_value); // Not equal
----

[[empty-types]]
=== Empty Types

Empty `record` and `set` types are not real built-in types in TTCN–3, but the Java realization of these types also differs from regular records or sets. The empty types are almost identical to each other, only their names are different.

Each empty type is defined in a Java class, which is generated by the Java code generator. Using separate classes enables us to differentiate among them in Java. For example, several empty types can be defined as incoming or outgoing types on the same TTCN–3 port type.

Let us consider the following TTCN–3 type definition as an example:
[source, subs="+quotes"]
type record Dummy {};

The generated class will rely on an enumerated Java type TitanNull_Type, which is defined as follows:
[source, subs="+quotes"]
----
public enum TitanNull_Type {
	NULL_VALUE
}
----

The only possible value stands for the TTCN–3 empty record or array value (that is for "{}"), which is the only possible value of TTCN–3 type `Dummy`. Note that this type and value is also used in the definition of `record` of and `set of` type construct.

The generated Java class `Dummy` will have the following member functions:

.Public member functions of the class `Dummy`

[width="100%",cols=",,",options="header",]
|================================================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`Dummy()` |Initializes to unbound value.
|`Dummy( final TitanNull_Type otherValue )` |Initializes to the only possible value.
|`Dummy( final Dummy otherValue )` |Copy constructor.
.3+^.^|_Assignment operators_
|`Dummy operator_assign( final TitanNull_Type otherValue )` |Assigns the only possible value and sets the bound flag.
|`Dummy operator_assign( final Dummy otherValue )` |
|`Dummy operator_assign( final Base_Type otherValue )`|
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1142
|boolean operator_equals( final TitanNull_Type otherValue )  |Returns true if both arguments are bound.
1143 1144
|boolean operator_equals( final Dummy otherValue ) |
|boolean operator_equals( final Base_Type otherValue )|
Kristof Szabados's avatar
Kristof Szabados committed
1145
|boolean operator_not_equals( final TitanNull_Type otherValue ) | Returns false if both arguments are bound.
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
|boolean operator_not_equals( final Base_Type otherValue ) |
.7+^.^|_Other member functions_
|`void log()` |Puts the value, that is, {}, into log.
|`boolean is_present()` |Returns whether the value is present.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
|`void clean_up()` |Deletes the value, setting it to unbound.
|`encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
|`void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|

|================================================================================

Setting the only possible value is important, because using the value of an unbound variable for anything will cause dynamic test case error.

== Compound Data Types

1162
The user-defined compound data types are implemented in Java classes. These classes are generated by the Java code generator according to type definitions. In contrast with the basic types, these classes can be found in the generated code.
1163 1164 1165

=== Record and Set Type Constructs

1166
The TTCN–3 type constructs `record` and `set` are mapped in an identical way to Java. There will be a Java class for each record type in the generated code. This class builds up the record from its fields.footnote:[This section deals with the record and set types that have at least one field. See <<empty-types, Empty Types>> for the Java mapping of empty record and set types.] The fields can be either basic or compound types.
1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180

Let us consider the following example type definition. The types `t1` and `t2` can be arbitrary.
[source]
----
type record t3 {
  t1 f1,
  t2 f2
}
----

The generated class `t3` will have the following public member functions:

.Public member functions of the class `t3`

1181
[width="100%",cols="20%,60%,20%",options="",]
1182 1183 1184 1185
|=====================================================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`t3()` |Initializes all fields to unbound value.
1186 1187 1188 1189 1190 1191
|`t3(final t1 f1, final t2 f2 )` |Initializes from given field values. The number of arguments equals to the number of fields.
|`t3( final t3 otherValue)` |Copy constructor.
.2+^.^|_Assignment operator_
|`t3 operator_assign(final t3 otherValue )`  |Assigns the given value and sets the bound flag for each field.
|`t3 operator_assign(final Base_Type otherValue)`|
.3+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1192
|boolean operator_equals( final t3 other_value) |Returns true if all fields are equal and false otherwise.
1193 1194
|boolean operator_equals(final Base_Type other_value)|
|boolean operator_not_equals( final t3 other_value) |
1195
.2+^.^|_Field access functions_
1196 1197 1198 1199 1200 1201 1202 1203
|t1 get_field_f1(); t2 get_field_f2() |Gives access to the first/second field.
|t1 constGet_field_f1(); t2 constGet_field_f2(); |The same, but it gives read-only access.
.8+^.^|_Other member functions_
|`TitanInteger size_of()` |Returns the size (number of fields).
|`void log()` |Puts the value into log. Like { f1 := 5, f2 := ”abc”}.
|`boolean is_present()` |Returns whether the value is present.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
1204
|`void clean_up()` |Deletes the value, setting it to unbound.
1205 1206
|`void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
|`void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
|=====================================================================================

The record value is unbound if one or more fields of it are unbound. Using the value of an unbound variable for anything (even for comparison) will cause dynamic test case error.

==== Optional Fields in Records and Sets

TTCN–3 permits optional fields in record and set type definitions. An optional field does not have to be always present, it can be omitted. But the omission must be explicitly denoted. Let us change our last example to this.
[source]
----
type record t3 {
  t1 f1,
  t2 f2 optional
}
----

1222
The optional fields are implemented using a Java generic class called `Optional` that creates an optional value from any type. In the definition of the generated class `t3`, the type `t2` will be replaced by `Optional<t2>` everywhere and anything else will not be changed.
1223

1224
The class `Optional<TYPE extends Base_Type>` has the following member functions:
1225

1226
.Table Public member functions of the class `Optional<TYPE extends Base_Type>`
1227

1228
[width="100%",cols="20%,60%,20%",options="",]
1229 1230
|================================================================================================================================================================================
2+^.^|*Member functions* |*Notes*
1231 1232 1233 1234 1235 1236 1237 1238 1239
.3+^.^|_Constructors_
|`Optional(final Class<TYPE> clazz)` |Initializes to unbound value, with a class.
|`Optional(final Class<TYPE> clazz, final template_sel otherValue)` |Initializes to omit value, if the argument is OMIT VALUE.
|`Optional(final Optional<TYPE> otherValue)`  |Copy constructor.
.3+^.^|_Assignment operators_
|`Optional<TYPE> operator_assign(final template_sel otherValue)` |Assigns omit value, if the right value is OMIT VALUE.
|`Optional<TYPE> operator_assign(final Optional<TYPE> otherValue)` |Assigns the given optional value.
|`Optional<TYPE> operator_assign(final Base_Type otherValue)`|
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1240 1241
|boolean operator_equals(final template_sel otherValue) |Returns true if the value is omit and the right side is OMIT VALUE or false otherwise.
|boolean operator_equals(final Optional<TYPE> otherValue) |Returns true if the two values are equal or false otherwise.
1242 1243 1244
|boolean operator_equals(final Base_Type otherValue)|
|boolean operator_not_equals(final template_sel otherValue)  |
|boolean operator_not_equals(final Optional<TYPE> otherValue) |
1245
.2+^.^|_Casting operators_
1246 1247 1248
|TYPE get() |Gives read-write access to the value. If the value was not previously present, sets the bound flag true and the value will be initialized to unbound.
|TYPE constGet() |Gives read-only access to the value. If the value is not present, causes a dynamic test case error.
.7+^.^|_Other member functions_
Kristof Szabados's avatar
Kristof Szabados committed
1249 1250 1251 1252
|`boolean ispresent()` |Returns true if the value is present, false if the value is omit or causes dynamic test case error if the value is unbound.
|`boolean is_present()` |Returns true if the value is present, false otherwise.
|`boolean is_value()` |Returns true if the value is present and is a value, false otherwise.
|`boolean is_bound()` |Returns true if the value is present or omit, false otherwise.
1253 1254
|`boolean is_optional()`| return true;
|`void log()` |Puts the optional value into log. Either ”omit” or the value of t2.
1255 1256 1257
|`void clean_up()` |Deletes the value, setting it to unbound.
|================================================================================================================================================================================

1258
In some member functions of the generic class `Optional` the enumerated Java type `template_sel` is used. It has many possible values, but in the optional class only `OMIT_VALUE` can be used, which stands for the TTCN–3 omit. Usage of other predefined values of `template_sel` will cause dynamic test case error.
1259 1260 1261 1262 1263

Using the value of an unbound optional field for anything will also cause dynamic test case error.

=== Union Type Construct

1264
The TTCN–3 type construct union is implemented in a Java class for each union type in the generated code. This class may contain any, but exactly one of its fields. The fields can be either basic or compound types or even identical types.
1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276

Let us consider the following example type definition. The types `t1` and `t2` can be arbitrary.
[source]
----
type union t3 {
  t1 f1,
  t2 f2
}
----

An ancillary enumerated type is created in the generated class `t3`, which represents the selection:
[source, subs="+quotes"]
1277
enum union_selection_type { UNBOUND_VALUE,  ALT_f1,  ALT_f2 };
1278

1279
The type `t3.union_selection_type` is used to distinguish the fields of the union. The predefined constant values are generated as `t3.ALT_`<field name>.
1280 1281 1282 1283 1284

The generated class `t3` will have the following public member functions:

.Public member functions of the class `t3`

1285
[width="100%",cols="20%,60%,20%",options="header",]
1286 1287 1288 1289
|=========================================================================================================================================================================
2+^.^|*Member functions* |*Notes*
.2+^.^|_Constructors_
|`t3()` |Initializes to unbound value.
1290 1291 1292 1293 1294
|`t3(final t3 otherValue)` |Copy constructor.
.2+^.^|_Assignment operator_
|`t3 operator_assign( final t3 otherValue )` |Assigns the given value.
|`t3 operator_assign( final Base_Type otherValue )`|
.3+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1295
|boolean operator_equals( final t3 otherValue ) |Returns true if the selections and field values are equal and false otherwise.
1296 1297
|boolean operator_equals( final Base_Type otherValue )|
|boolean operator_not_equals( final t3 otherValue ) |
1298
.4+^.^|_Field access functions_
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
|t1 constGet_field_f1()  |Gives read-only access to the first field. If other field is selected, this function will cause a dynamic test case error. So use get_selection() first.
|t1 get_field_f1() | Selects and gives access to the first field. If other field was previously selected, its value will be destroyed.
|t2 constGet_field_f2() |
|t2 get_field_f2() |
.9+^.^|_Other member functions_
|`union_selection_type get_selection()` |Returns the current selection. It will return t3.UNBOUND VALUE if the value is unbound, t3.ALT_f1 if the first field was selected, and so on.
|`boolean ischosen(final union_selection_type checked_selection)`| Checks if the provided field is selected or not.
|`void log()` |Puts the value into log. Example: { f1 := 5 } or { f2 := "abc" }.
|`boolean is_present()` |Returns whether the value is present.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
1310
|`void clean_up()` |Deletes the value, setting it to unbound.
1311 1312
|`void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
|`void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
1313 1314 1315 1316 1317 1318
|=========================================================================================================================================================================

Using the value of an unbound `union` variable for anything will cause dynamic test case error.

==== The anytype

1319
The TTCN-3 anytype is implemented as a Java class named anytype. It has the same interface as any other Java class generated for a union, with a few differences:
1320

1321
If a field is a built-in type or the address type, the name used in `union_selection_type` is the name of the runtime class implementing the type.
1322 1323 1324

If a field is a user-defined type, the mapping rules in <<mapping-of-names-and-identifiers, Mapping of Names and Identifiers>> above apply.

1325
The names of field accessor functions are prefixed with `get_field_` or `constGet_field_` as with other unions.
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343

For example, for the following module
[source]
----
module anyuser {
  type record myrec {}

  control {
    var anytype v_at;
  }
}
with {
  extension “anytype integer, myrec, charstring”
}
----

The generated class name will be "anytype". The union_selection_type enumerated type will be:
[source, subs="+quotes"]
1344
enum union_selection_type { UNBOUND_VALUE,  ALT_TitanInteger,  ALT_myrec,  ALT_TitanCharString };
1345 1346 1347 1348

The field accessor methods will be:
[source]
----
1349 1350 1351
TitanInteger get_field_TitanInteger();
myrec get_field_myrec();
TitanCharString get_field_TitanCharString();
1352 1353 1354 1355
----

=== Record of Type Construct

1356
The TTCN–3 type construct `record` of makes a variable length sequence from one given type. This construct is implemented as a Java class.
1357 1358 1359 1360 1361

Let us consider the following example type definition. The type t1 can be arbitrary.
[source, subs=+quotes]
type record of t1 t2;

1362
This definition will be translated to a Java class that will be called t2.
1363

1364
There is an `enum` type called `TitanNull_Type` defined in the Base Library that has only one possible value. `NULL_VALUE` stands for the empty `"record of"` value, that is, for {}.
1365 1366 1367 1368 1369

Class `t2` will have the following public member functions:

.Public member functions of the class `t2`

1370
[width="100%",cols="20%,60%,20%",options="",]
1371 1372 1373 1374
|==================================================================================================================================================================================================================
2+^.^|*Member functions* |*Notes*
.3+^.^|_Constructors_
|`t2()` |Initializes to unbound value.
1375 1376 1377 1378 1379 1380 1381
|`t2(final TitanNull_Type nullValue)` |Initializes to the empty value.
|`t2( final t2 otherValue )` |Copy constructor.
.3+^.^|_Assignment operator_
|`t2 operator_assign(final TitanNull_Type nullValue)` |Assigns the empty value.
|`t2 operator_assign( final t2 otherValue )` |Assigns the given value.
|`t2 operator_assign(final Base_Type otherValue)`|
.5+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1382
|boolean operator_equals( final TitanNull_Type nullValue)  |Returns true if the two values are equal and false otherwise.
1383 1384 1385 1386
|boolean operator_equals( final t2 otherValue ) |
|boolean operator_equals(final Base_Type otherValue)|
|boolean operator_not_equals( final TitanNull_Type nullValue) |
|boolean operator_not_equals( final t2 otherValue ) |
1387
.4+^.^|_Index operators_
1388 1389 1390 1391
|t1 get_at(final int index_value) |Gives access to the given element. Indexing begins from zero. If this element of the variable was never used before, new (unbound) elements will be allocated up to (and including) this index.
|t1 get_at(final TitanInteger index_value) |
|t1 constGet_at(final int index_value) |Gives read-only access to the given element. Index overflow causes dynamic test case error.
|t1 constGet_at(final TitanInteger index_value) |
1392
.4+^.^|_Rotating operators_
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409
|t2 rotate_left(final int rotate_count) |Java equivalent of operator <@. (rotate left)
|t2 rotate_left(final TitanInteger rotate_count) |
|t2 rotate_right(final int rotate_count) |Java equivalent of operator @>. (rotate right)
|t2 rotate_right(final TitanInteger rotate_count) |
.2+^.^|_Concatenation operator_
|t2 operator_concatenate(final t2 other_value) |Concatenates two arrays.
|t2 operator_concatenate(final TitanNull_Type null_value)|
.5+^.^|_Other member functions_
|`TitanInteger size_of()` |Returns the number of elements, that is, the largest used index plus one and zero for the empty value.
|`void set_size(final int newSize)` |Sets the number of elements to the given value. If the value has fewer elements new (unbound) elements are allocated at the end. The excess elements at the end are erased if the value has more elements than necessary.
|`t2 substr(final int index, final int returncount)` |Returns the section of the array specified by the given start index and length.
|`t2 replace(final int index, final int len, final t2 repl)` |Returns a copy of the array, where the section indicated by the given start index and length is replaced by the given array.
|`void log()` |Puts the value into log. Like {1, 2, 3 }.
.6+^.^|_Other member functions_
|`boolean is_present()` |Returns whether the value is present.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
1410
|`void clean_up()` |Deletes the value, setting it to unbound.
1411 1412
|`void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
|`void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
1413 1414 1415 1416 1417 1418 1419 1420
|==================================================================================================================================================================================================================

A `record of` value is unbound if no value has been assigned to it or it has at least one unbound element. Using the value of an unbound `record of` variable for anything will cause dynamic test case error.

Starting with the largest index improves performance when filling a `record of value`.

==== Pre-generated `record of` and `set of` constructs

1421
The Java classes for the `record of` and `set of` constructs of most predefined TTCN-3 types are pre-generated and part of the TITAN runtime. For instances of these types declared in TTCN-3 and ASN.1 modules only their pre-generated names are used (and a comment telling which type definition it is representing). There is a class with regular memory allocation and one with optimized memory allocation pre-generated for each type. These classes are located in the `PreGenRecordOf` class inside the runtime.
1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465

.Pre-generated classes for `record of`/`set of` predefined types

[width="100%",cols="50%,50%",options="header",]
|====================================================================================================================================
|{cpp} class name |Equivalent type in TTCN-3
|`PREGEN\__RECORD__OF__BOOLEAN` |`record of boolean`
|`PREGEN\__RECORD__OF__INTEGER` |`record of integer`
|`PREGEN\__RECORD__OF__FLOAT` |`record of float`
|`PREGEN\__RECORD__OF__BITSTRING` |`record of bitstring`
|`PREGEN\__RECORD__OF__HEXSTRING` |`record of hexstring`
|`PREGEN\__RECORD__OF__OCTETSTRING` |`record of octetstring`
|`PREGEN\__RECORD__OF__CHARSTRING` |`record of charstring`
|`PREGEN\__RECORD__OF\__UNIVERSAL__CHARSTRING` |`record of universal charstring`
|`PREGEN\__RECORD__OF\__BOOLEAN__OPTIMIZED` |`record of boolean with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__INTEGER__OPTIMIZED` |`record of integer with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__FLOAT__OPTIMIZED` |`record of float with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__BITSTRING__OPTIMIZED` |`record of bitstring with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__HEXSTRING__OPTIMIZED` |`record of hexstring with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__OCTETSTRING__OPTIMIZED` |`record of octetstring with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__CHARSTRING__OPTIMIZED` |`record of charstring with { extension "optimize:memalloc" }`
|`PREGEN\__RECORD__OF\__UNIVERSAL__CHARSTRING__OPTIMIZED` |`record of universal charstring with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF__BOOLEAN` |`set of boolean`
|`PREGEN\__SET__OF__INTEGER` |`set of integer`
|`PREGEN\__SET__OF__FLOAT` |`set of float`
|`PREGEN\__SET__OF__BITSTRING` |`set of bitstring`
|`PREGEN\__SET__OF__HEXSTRING` |`set of hexstring`
|`PREGEN\__SET__OF__OCTETSTRING` |`set of octetstring`
|`PREGEN\__SET__OF__CHARSTRING` |`set of charstring`
|`PREGEN\__SET__OF\__UNIVERSAL__CHARSTRING` |`set of universal charstring`
|`PREGEN\__SET__OF\__BOOLEAN__OPTIMIZED` |`set of boolean with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__INTEGER__OPTIMIZED` |`set of integer with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__FLOAT__OPTIMIZED` |`set of float with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__BITSTRING__OPTIMIZED` |`set of bitstring with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__HEXSTRING__OPTIMIZED` |`set of hexstring with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__OCTETSTRING__OPTIMIZED` |`set of octetstring with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__CHARSTRING__OPTIMIZED` |`set of charstring with { extension "optimize:memalloc" }`
|`PREGEN\__SET__OF\__UNIVERSAL__CHARSTRING__OPTIMIZED` |`set OF\ universal charstring with { extension "optimize:memalloc" }`
|====================================================================================================================================

=== `Set of` Type Construct

The `set of` construct of TTCN–3 is implemented similarly to `record of`. The external interface of this class is exactly the same as in case of `record of`. For more details please see the previous section.

1466
In the internal implementation only the equality operator differs. Unlike in `record of`, it considers the unordered property of the `set of` type construct, that is, it returns `true` if it is able to find exactly one pair for each element.
1467

1468
The index is a unique identifier for a `set of` element because the Java class does not reorder the elements when a new element is added or an element is modified. The copy constructor also keeps the original order of elements.
1469 1470 1471

=== Enumerated Types

1472
The TTCN–3 `enumerated` type construct is implemented as a Java class with an embedded enum type.
1473 1474 1475
[source, subs="+quotes"]
type enumerated Day { Monday (1), Tuesday, Wednesday (3) };

1476
The example above will result in the following, very similar Java `enum` type definition which is embedded in the Java class `Day`:
1477
[source, subs="+quotes"]
1478 1479 1480 1481 1482 1483 1484 1485 1486
----
public enum enum_type {
			Monday (1),
			Tuesday (0),
			Wednesday (3),
			UNKNOWN_VALUE(2),
			UNBOUND_VALUE(4);
      ...
----
1487

1488
The automatic assignment of numeric values is done according to the standard. Note that there are two extra enumerated values in Java, which stand for the unknown and unbound values. They are used in the conversion functions described below. The Java code generator assigns the smallest two non-negative integer numbers that are not used by the user-defined enumerated values to the unknown and unbound values.
1489

1490
When using the Java `enum` type and its values from user code the names must be prefixed with the Java class name. The `enum` type in the above example can be referenced with `Day.enum_type`, its values can be accessed as `Day.enum_type.Monday, Day.enum_type.Tuesday`, and so on.
1491 1492 1493 1494 1495

The class `Day` will have the following public member functions:

.Public member functions of the class `Day`

1496
[width="100%",cols="20%,60%,20%",options="",]
1497 1498 1499 1500
|=========================================================================================================================
2+^.^|*Member functions* |*Notes*
.4+^.^|_Constructors_
|`Day()` |Initializes to unbound value.
1501
|`Day(final int otherValue)` |Converts the given numeric value to Day.enum_type and initializes to it.
1502
Only valid values are accepted.
1503 1504 1505
|`Day(final Day.enum_type otherValue )` |Initializes to a given value.
|`Day(final Day otherValue)`  |Copy constructor.
.4+^.^|_Assignment operator_
Kristof Szabados's avatar
Kristof Szabados committed
1506
|`Day operator_assign(final int otherValue)` |Converts the given numeric value to Day.enum_type and assigns it. Only valid values are accepted.
1507 1508 1509 1510
|`Day operator_assign(final Day.enum_type otherValue)` |Assigns the given value.
|`Day operator_assign(final Day otherValue)` |
|`Day operator_assign(final Base_Type otherValue)`|
.6+^.^|_Comparison operators_
Kristof Szabados's avatar
Kristof Szabados committed
1511
|boolean operator_equals(final Day.enum_type otherValue) |Returns true if the two values are equal and false otherwise.
1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542
|boolean operator_equals(final Day otherValue)|
|boolean operator_equals(final Base_Type otherValue)|
|boolean operator_not_equals(final Day.enum_type otherValue) |
|boolean operator_not_equals(final Day otherValue) |
|boolean operator_not_equals(final Base_Type otherValue)|
.8+^.^|_Comparison operators_
|boolean is_less_than(final Day.enum_type otherValue) |
|boolean is_less_than(final Day otherValue)|
|boolean is_less_than_or_equal(final Day.enum_type otherValue) |
|boolean is_less_than_or_equal(final Day otherValue) |
|boolean is_greater_than(final Day.enum_type otherValue) |
|boolean is_greater_than(final Day otherValue) |
|boolean is_greater_than_or_equal(final Day.enum_type otherValue) |
|boolean is_greater_than_or_equal(final Day otherValue) |
.6+^.^|_Static conversion functions_
|static String enum_to_str(final enum_type enumPar) |See below.
|static enum_type str_to_enum(final String strPar)  |
|static boolean is_valid_enum(final int other_value) |
|boolean is_valid_enum(final enum_type other_value)|
|static int enum2int(final Day enumPar) |
|static int enum2int(final Day.enum_type enumPar) |
.4+^.^|_Non-static conversion functions_
|int as_int(); |See below
|void from_int(final int intValue); |
|void int2enum(final int intValue); |
|void int2enum(final TitanInteger intValue); |
.7+^.^|_Other member functions_
|`void log()` |Puts the value into log. Like this: Monday
|`boolean is_preset()` |Returns whether the value is present.
|`boolean is_bound()` |Returns whether the value is bound.
|`boolean is_value()` |Returns whether the value is a value.
1543
|`void clean_up()` |Deletes the value, setting it to unbound.
1544 1545
|`void encode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
|`void decode(final TTCN_Typedescriptor p_td, final TTCN_Buffer p_buf, final coding_type p_coding, final int flavour)`|
1546 1547
|=========================================================================================================================

1548
The static member function `Day.enum_to_str` converts the given parameter of type `Day.enum_type` to a Java String. It returns the string "<unknown>", if the input is not a valid value of the TTCN–3 enumerated type. The returned string is read-only.
1549

1550
The function `Day.str_to_enum` does the conversion in the reverse direction. It converts the symbolic enumerated identifier represented by a Java String back to the `Day.enum_type` equivalent. It returns the value `Day.UNKNOWN_VALUE` if the input string is not the equivalent of any of the possible values in the enumerated type.
1551

1552
In the above two functions the strings are treated case sensitive and they shall not contain any whitespace or other characters that are not part of the enumerated value. In case of ASN.1 `ENUMERATED` types the strings used by `enum_to_str`, `str_to_enum` and log represent the TTCN–3 view of the enumerated value, that is, the hyphenation characters are mapped to a single underscore character. For example, if an ASN.1 enumerated type has a value with name `my-enum-value` and numeric value 2, the function `enum_to_str` will return the string `"my_enum_value"` if the input parameter equals to 2. Of course, its Java equivalent will be `my_enum_value` with numeric value 2.
1553

1554
Static member function `Day.is_valid_enum` returns the boolean value `true` if there is a defined enumerated value having numeric value equal to the `int` parameter and `false` otherwise.
1555

1556
The static member function `Day.enum_to_int` converts the given parameter of type Day or `Day.enum_type` to its numeric value. The member function `as_int` does the same thing for the enumerated instance.
1557 1558 1559

The member function `int_to_enum` initializes the enumerated instance with the enumerated value having numeric value equal to the given `int` parameter. A dynamic test case error is displayed if there is no such enumerated value. The member function `from_int` does the same thing.

1560
If a value of type `int` is passed to the constructor or assignment operator the value is accepted only if it is a numerical representation of a valid enumerated value, that is, the function `is_valid_enum` returns `true`. A dynamic test case error occurs otherwise.
1561 1562 1563 1564 1565 1566

To avoid run-time errors at the decoding of invalid messages the Test Port writer should use the constructor or assignment operator in this way:
[source]
----
Day myDayVar;
int myIntVar = buffer[position];
1567 1568 1569 1570 1571
if (Day.is_valid_enum(myIntVar)) {
  myDayVar = new Day(myIntVar);
} else {
  myDayVar = new Day(Day.enum_type.UNKNOWN_VALUE);
}
1572 1573 1574 1575 1576 1577
----

Using the value of an unbound enumerated variable for anything will cause dynamic test case error.

=== The `address` Type

1578 1579
The special TTCN–3 data type `address` is represented in Java as if it was a regular data type. The name of the equivalent Java class is `ADDRESS`.

1580 1581
== Predefined Functions

1582
Annex C of link:https://www.etsi.org/deliver/etsi_es/201800_201899/20187301/04.05.01_60/es_20187301v040501p.pdf[Methods for Testing and Specification (MTS); The Testing and Test Control Notation version 3. Part 1: Core Language European Telecommunications Standards] and Annex B of link:https://pdfs.semanticscholar.org/33b5/877c85f7fd4f35c7f58c39121358c3652966.pdf[Methods for Testing and Specification (MTS); The Testing and Test Control Notation version 3. Part 7: Using ASN.1 with TTCN–3 European Telecommunications] define a couple of predefined functions. Most of them perform conversion between the built-in types of TTCN–3. In our test executor these functions are implemented in the Base Library in Java language. They are available not only in TTCN–3 , but they can be called directly from Test Ports as well.
1583

1584
The implementation of these functions can be found in the class `AdditionalFunctions` in the runtime library, but for easier navigation we list them also in the present document.
1585

1586
The majority of these functions have more than one polymorphic version: when appropriate, one of them takes literal (built-in) Java types as arguments instead of the objects of equivalent Java classes. For instance, if the incoming argument is stored in an `int` variable in your Java code, you should not construct a temporary object of class `TitanInteger` because passing an `int` is faster and produces smaller binary code. Similarly, the returned type is also literal when it is possible.
1587 1588 1589 1590 1591

=== `Integer` to character

[source]
----
1592 1593
TitanCharString int2char(final int value);
TitanCharString int2char(final TitanInteger value);
1594 1595 1596 1597 1598
----
=== Character to `integer`

[source]
----
1599 1600 1601 1602
TitanInteger char2int(final char value);
TitanInteger char2int(final String value);
TitanInteger char2int(final TitanCharString value);
TitanInteger char2int(final TitanCharString_Element value);
1603 1604 1605 1606 1607
----
=== `Integer` to universal character

[source]
----
1608 1609
TitanUniversalCharString int2unichar(final int value);
TitanUniversalCharString int2unichar(final TitanInteger value);
1610 1611 1612 1613 1614
----
=== Universal character to `integer`

[source]
----
1615 1616 1617
TitanInteger unichar2int(final TitanUniversalChar value);
TitanInteger unichar2int(final TitanUniversalCharString value);
TitanInteger unichar2int(final TitanUniversalCharString_Element value);
1618 1619 1620 1621 1622
----
=== `Bitstring` to `integer`

[source]
----
1623 1624
TitanInteger bit2int(final TitanBitString value);
TitanInteger bit2int(final TitanBitString_Element value);
1625 1626 1627 1628 1629
----
=== `Hexstring` to `integer`

[source]
----
1630 1631
TitanInteger hex2int(final TitanHexString value);
TitanInteger hex2int(final TitanHexString_Element value);