String Type

Use the String primitive type to define String variables and attributes. A string contains zero or more characters. A null string is a string that has a zero length ("").

A string containing embedded null characters can be assigned to a local String variable and passed as a String parameter. Assigning a string containing embedded null characters to a String attribute may result in truncation of the string at the first null character.

To safely pass a string variable containing embedded null characters from JADE to an external method, define the string parameter in JADE as io usage.

When you specify a length less than 540 for a String attribute, it is embedded. Space is allocated within instances of the class to store a string with a length less than or equal to the specified length.

When you specify a length greater than or equal to 540 or you select the Maximum Length check box, which corresponds to 2,147,483,647 characters, for a String attribute, it is not embedded. It is stored in a separate variable-length object, a String Large Object (slob), which can store a string with a length less than or equal to the specified length. The amount of storage required for a slob is determined by the value of the string.

String variables can be bounded or unbounded, as shown in the following code fragment.

vars
   str1 : String[100]; // Bounded - str1 can store a string with a
                       // length less than or equal to 100 characters
   str2 : String;      // Unbounded - str2 can store a string with a length
                       // less than or equal to 2,147,483,647 characters

The ordering relationship of the character values in corresponding positions sets the ordering between two string values. In strings of unequal length, each character in the longer string without a corresponding character in the shorter string takes on a greater-than value; for example, Zs is greater than Z. Null strings can be equal only to other null strings.

To specify a substring str[m:n] of a string str, two integers separated by a colon (:) character are used. In substrings, the first integer is the start position, and the second integer (following the colon (:) character) is the length of the substring or end, to indicate the end of the string. The first character is defined as being at position 1.

If the length of a substring is zero (0), a null string ("") is returned.

A variable of type Character can be used to reference a single character in a string, in effect treating the string as an array of characters, as shown in the following code fragment.

vars
   str  : String;
   char : Character;
begin
   str  := "JADE Primitive Types";
   char := str[7];        // seventh character of the string, which is 'r'

For details about the methods defined in the String primitive type, see "String Methods", in the following subsection. For details about converting primitive types, see "Converting Primitive Types", in Chapter 1 of the JADE Developer’s Reference.