EGL primitives and Java

EGL converts primitive data types back and forth between EGL and Java™. Five different tables are required to describe the possible conversions:

These tables expose limitations in the underlying technologies. For example, when you call an ExternalType function, an EGL TIMESTAMP converts to a java.lang.Timestamp class. That class is not available in JSF, so the EGL TIMESTAMP converts to java.util.Calendar in a JSF handler.

In the following tables, some EGL primitives convert to classes (such as java.math.BigDecimal) and some convert to Java primitives (such as long).

ExternalType functions

The following table shows how EGL primitive types are converted to Java data types in an ExternalType function call. This is the only mapping in which EGL-to-Java conversions are not simply a mirror image of Java to EGL. A question mark indicates a nullable type; for more information, see "Null values and the nullable type."

Table 1. EGL-to-Java conversions
EGL type Java type
CHAR, CHAR?, MBCHAR, MBCHAR?, DBCHAR, DBCHAR?, UNICODE, UNICODE? java.lang.String, with trailing blank removal/padding and truncation on transitions
UNICODE(1) char
UNICODE(1)? java.lang.Character
STRING java.lang.String
HEX(2) byte
HEX(2)? java.lang.Byte
HEX(>2), HEX(>2)? byte[]
BOOLEAN boolean
BOOLEAN? java.lang.Boolean
SMALLINT short
SMALLINT? java.lang.Short
INT int
INT? java.lang.Integer
BIGINT long
BIGINT? java.lang.Long
DECIMAL, BIN, MONEY, NUM (no decimal places)

1<=length<=9, int
10<=length<=18, long
19<=length<=32, java.math.BigInteger

DECIMAL?, BIN?, MONEY?, NUM? (no decimal places)

1<=length<=9,  java.lang.Integer
10<=length<=18,  java.lang.Long
19<=length<=32, java.math.BigInteger

DECIMAL, DECIMAL?, BIN, BIN?, MONEY, MONEY?, NUM, NUM? (declared with decimal places) java.math.BigDecimal
SMALLFLOAT float
SMALLFLOAT? java.lang.Float
FLOAT double
FLOAT? java.lang.Double
DATE, DATE? java.sql.Date
TIME, TIME? java.sql.Time
TIMESTAMP, TIMESTAMP? java.sql.Timestamp
INTERVAL, INTERVAL? (microseconds) java.math.BigInteger (microseconds)
INTERVAL, INTERVAL? (months) long (months)
BLOB n/a
CLOB n/a
Dynamic array java.util.List. The elements of the dynamic array are converted to Java types according to this table. In other words, an array of EGL DATEs are converted to a java.util.List whose elements are java.sql.Date objects.

The following table shows how Java data types are converted to EGL primitive types in an ExternalType function call. An asterisk in the table below indicates the conversion is a mirror of the EGL-to-Java conversion.

Table 2. Java to EGL conversions
Java type EGL type
char* UNICODE(1)
java.lang.Character* UNICODE(1)?
java.lang.String* STRING
byte* HEX(2)
byte[n] HEX(n*2)?
java.lang.Byte* HEX(2)?
boolean* BOOLEAN
java.lang.Boolean* BOOLEAN?
short* SMALLINT
java.lang.Short* SMALLINT?
int* INT
java.lang.Integer* INT?
long* BIGINT
java.lang.Long* BIGINT?
java.math.BigDecimal DECIMAL(32,scale). java.math.BigDecimal has an unlimited number of digits; EGL is limited to 32 in Java generation.
java.math.BigInteger NUM(32). java.math.BigInteger has unlimited number of digits; EGL is limited to 32 in Java generation.
float* SMALLFLOAT
java.lang.Float* SMALLFLOAT?
double* FLOAT
java.lang.Double* FLOAT?
java.sql.Date DATE?
java.sql.Time TIME?
java.sql.Timestamp TIMESTAMP("yyyyMMddHHmmssfff")?
java.util.List* DynamicArray. The List is converted to an EGL dynamic array whose type is determined by the type of the List's elements. For example, if the List contains java.lang.Double objects, the EGL dynamic array is a FLOAT?[] type.

Report functions

In XML report design documents, data types are described as Java data types. If you invoke EGL JasperReport handler functions from the design document, the invocation should use the Java data type that corresponds to the applicable EGL primitive type. You must also declare the data that the JasperReport handler function returns to the XML design file in terms of Java data types.

The following table shows the Java data types to use in XML report design documents and the corresponding EGL primitive types.

Table 3. Converting EGL to Java for reports
EGL primitive type Java data type
BIGINT java.lang.Long
BIN java.math.BigDecimal
BLOB n/a
BOOLEAN java.lang.Boolean
CHAR java.lang.String
CLOB n/a
DATE java.util.Date
DBCHAR java.lang.String
DECIMAL java.math.BigDecimal
FLOAT java.lang.Double
HEX java.lang.Byte
INT java.lang.Integer
INTERVAL java.lang.String
MBCHAR java.lang.String
MONEY java.math.BigDecimal
NUM java.math.BigDecimal
NUMC java.math.BigDecimal
PACF java.math.BigDecimal
SMALLFLOAT java.lang.Float
SMALLINT java.lang.Short
STRING java.lang.String
TIME java.sql.Time
TIMESTAMP java.sql.Timestamp
UNICODE java.lang.String

JavaLib functions

When you pass an argument to a function from the JavaLib EGL system library, EGL converts the argument to the Java type shown in the following table. The return value is converted from the type in the right column to the corresponding type in the left column.

Table 4. Passing arguments to JavaLib functions
EGL type Examples Java type
String literal or a CHAR, DBCHAR, MBCHAR, or UNICODE variable No cast
"myString"
java.lang.String
Cast objID:java, which indicates an identifier
"myId" as 
   "objID:java"

x = "myId";
x as "objID:java"
The class of the object to which the identifier refers
Cast from null, as might be appropriate to provide a null reference to a fully qualified class
NULL as "java:
java.lang.Thread"

x = "java.util.
HashMap";
NULL as x
The specified class
Note: You cannot pass in a null-cast array such as 'null as "java:int[]" '
Cast with java:char, which means that the first character of the value is passed (each example in the next column passes an "a")
"abc" as "java:char"

x = "abc";
x as "java:char"
char
STRING variable No cast myStringVar java.lang.String
FLOAT variable 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
BOOLEAN variable No cast
myBoolean
boolean
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 as
java:java.math.-
BigDecimal,
BigInteger,
java:byte,
java:double,
java:float,
java:short,
java:int,
java:long

x = 42;

x as "java:byte"

x as "java:long"
The specified type; however, if the value is out of range for that type, loss of precision occurs and the sign might change
Cast with java:boolean, which means that non-zero is true, zero is false
x = 1;
x as "java:boolean"
boolean

JSF handler functions

The following table shows EGL-to-Java conversions that EGL performs when passing arguments from a JSF handler to a Java function. The function's return value is converted from a Java type to an EGL type. If you pass an EGL null argument to the function, it returns a Java null value.

Table 5. Conversions for JSF handlers
EGL type Java type
BIGINT / BIN(18) java.lang.Long
BIN with decimals java.math.BigDecimal
BLOB byte[]
BOOLEAN* java.lang.Boolean
CHAR java.lang.String
CLOB java.lang.String
DATE java.util.Date
DBCHAR java.lang.String
DECIMAL java.math.BigDecimal
FLOAT java.lang.Double
HEX byte[]
INT / BIN(9) java.lang.Integer
INTERVAL java.lang.String
MBCHAR java.lang.String
MONEY java.math.BigDecimal
NUM java.math.BigDecimal
NUMC java.math.BigDecimal
PACF java.math.BigDecimal
SMALLFLOAT java.lang.Float
SMALLINT / BIN(4) java.lang.Short
STRING java.lang.String
TIME java.util.Date
TIMESTAMP java.util.Calendar
UNICODE java.lang.String
Record An object conforming to the JavaBeans™ specification (the object has methods to get the values of the record's fields)
*A variable based on any of the following primitive types can have its IsBoolean property set to YES:
  • CHAR
  • BIN
  • NUM
  • NUMC
  • DECIMAL
  • PACF
  • INT
  • BIGINT
  • SMALLINT
  • FLOAT
  • MONEY

In this case, the variable is treated just like an actual BOOLEAN, mapping to java.lang.Boolean.


Feedback