ExternalType stereotype JavaObject

An ExternalType part with the JavaObject stereotype defines how you can access an external Java™ class or interface from your EGL code. The part typically identifies all the public fields, methods, and constructors of the class or interface, but might identify a subset of interest.

Syntax



Syntax diagram for the external type

name
The name of the external type
ExternalType
An external type that the current one extends or implements, depending on whether ExternalType represents a Java class or interface. The external type being defined includes the fields and function prototypes from ExternalType, but not the constructor prototypes.

EGL predefines the Serializable external type, which you can reference if you are defining an external type that is based on a Java class that itself implements the java.io.Serializable interface. If the external type that you are defining does not extend the EGL Serializable external type, any EGL variables that are based on that external type are marked as transient in the generated Java code. Transient variables are not preserved when a Java object is serialized by a runtime platform such as an application server. For example, serialization might occur when the server creates a backup copy of the object in response to a shut down.

@annotation
The following type-level annotations are available:
packageName
A string that holds the package name for the external Java type.
externalName
A string that holds the Java type name. This value is optional and defaults to the name of the external type. However, you must set this value in some cases; for example, if the Java type name is an EGL reserved word, the external type name must be different from the Java type name.
static
An indicator to state that the variable or function is global to the class and is independent of whether the class has any objects. You can access a static variable or function by referencing the external type without referencing an object (for example, MyType.theStaticVariable), or by referencing an object (for example, MyObject.theStaticVariable).
constructorPrototype
An EGL function prototype that corresponds to a Java constructor. You can pass the following kinds of parameters:
  • A primitive-type value. You must specify the in modifier.
  • A dynamic array. You can specify the in, out, or inout modifier.
  • A structured record. You must specify the inout modifier.
functionPrototype
An EGL function prototype that corresponds to a Java method. You can pass the following kinds of parameters:
  • A primitive-type value. You must specify the in modifier.
  • A dynamic array. You can specify the in, out, or inout modifier.
  • A structured record. You must specify the inout modifier.

The function can return a primitive-type value, an array, or no value at all. The function cannot return a record.

@Throws{}
The Throws annotation is available on a constructor or function prototype. The setting allows the EGL compiler to catch an error (a lack of response to a thrown exception) that would otherwise be caught only by the Java compiler.

The annotation has no fields.

variableList
An EGL variable or comma-separated list of EGL variables. Each EGL variable corresponds to a Java field and might be based on a Java primitive, an EGL external type, or an array of primitives or external types.
Variable or function declarations can include the following property:
externalName
A string that contains the name of the related field or method in the Java class. This property is optional and defaults to the name of the variable or function in the external type. However, you must specify a custom name in some cases (for example, if the field name is an EGL reserved word), and in those cases, you must specify the externalName property. Here is an example:
Function nextElement() { externalName = "next" };
Variable declarations can also include the following annotations:

When you reference Java field and method names in the code, remember that they are case sensitive, even though the equivalent EGL names are not.