When you use the Java™ access functions for EGL (see "Java access functions"), each of the arguments you pass to a method (and each value that you assign to a field) is mapped to a Java object or primitive type. Variables of EGL primitive type CHAR, for example, are passed as objects of the Java String class.
No mapping exists between EGL arrays and Java lists, as you cannot use EGL arrays with these functions. To pass an array to a Java function, create an ExternalType part (see ExternalType part). This is the preferred way to interact with Java objects.
Use the as cast operator for situations in which the mapping of EGL types to Java types is not sufficient. This is a special case of the as operator called a foreign language cast; for more information see the as operator.
When you specify a Java name, EGL strips both single-byte and double-byte blanks from the beginning and end of the case-sensitive value. The truncation precedes any cast. This rule applies to string literals and to variables of type CHAR, DBCHAR, MBCHAR, or UNICODE. This truncation does not occur when you specify either a method argument or field value (for example, the string " my data " is passed to a method as is), unless you cast the value to objID or null.
The next table describes the valid mappings.
Category of Argument | Examples | Java Type | |
---|---|---|---|
String literal, or a CHAR, DBCHAR, MBCHAR, or UNICODE variable | No cast | "myString" |
java.lang.String |
Cast with objID, which indicates an identifier | (objID)"myId" x = "myId"; (objID)X |
The class of the object to which the identifier refers | |
Cast with null, as can be appropriate to provide a null reference to a fully qualified class | (null)"java. lang.Thread" x = "java.util. HashMap"; (null)x |
The specified class Note: You
cannot pass in
a null-cast array such as (null)"int[]"
|
|
Cast with char, which means that the first character of the value is passed (each example in the next column passes an "a") | (char)"abc" X = "abc"; (char)X |
char | |
STRING variable | No cast | myStringVar | java.lang.String |
FLOAT variable or a floating point literal | No cast | myFloatValue |
double |
HEX variable | No cast | myHexValue |
byte array |
SMALLFLOAT variable | No cast | mySmallFloat |
float |
DATE variable | No cast | myDate |
java.sql.Date |
TIME variable | No cast | myTime |
java.sql.Time |
TIMESTAMP variable | No cast | myTimeStamp |
java.sql.Timestamp |
INTERVAL variable | No cast | myInterval |
java.lang.String |
Floating point literal | No cast | -6.5231E96 | double |
Numeric variable (or non-floating-point literal) that does not contain decimals; leading zeros are included in the number of digits for a literal | No cast, 1-4 digits | 0100 |
short |
No cast, 5-9 digits | 00100 |
int | |
No cast, 9-18 digits | 1234567890 |
long | |
No cast, >18 digits | 1234567890123456789 |
java.math.BigInteger | |
Numeric variable (or non-floating-point literal) that contains decimals; leading and trailing zeros are included in the number of digits for a literal | No cast, 1-6 digits | 3.14159 |
float |
No cast, 7-18 digits | 3.14159265 |
double | |
No cast, >18 digits | 56789543.222 |
java.math.BigDecimal | |
Numeric variable or non-floating-point literal, with or without decimals | Cast with bigdecimal, biginteger, byte, double, float, short, int, long | X = 42; (byte)X (long)X |
The specified primitive type; however, if the value is out of range for that type, loss of precision occurs and the sign might change |
Cast with boolean, which means that non-zero is true, zero is false | X = 1; (boolean)X |
boolean |
To avoid losing precision, use an EGL FLOAT variable for a Java double, and an EGL SMALLFLOAT variable for a Java float. Using one of the other EGL types can result in a rounding error. For information about the internal format of variables in EGL, see Primitive data types.