Introduction to ExternalType parts

ExternalType parts map EGL to external language elements.

This mapping is similar to the mapping that an Interface part provides for Service functions, but mapping EGL to external language elements is generalized to include fields and constructors. The only external element that ExternalType part supports is the Java™ object.

An ExternalType part consists of the following components:
Variable declarations
These provide access to public variables in the external language element.
Function prototypes
These represent method invocations or function calls in the external type.
Constructor prototypes
These define the syntax for constructing a variable of this external type using an EGL new statement.

The concept of the ExternalType is similar to that of a Library or a Service. In each of these cases, you use external functionality within your program. In the case of the Service or the ExternalType, where EGL does not have direct access to the code, you must provide certain prototypes so that EGL can perform the necessary type checking.

An ExternalType definition reserves no storage. You must declare a variable that is based on the part, optionally using the EGL new statement, to use its variables and functions (unless they are declared to be static; see "Syntax" in this topic).

A number of the concepts used with the ExternalType part come from object-oriented languages, such as Java and C#. These concepts include extension, inheritance, and constructors. If you are unfamiliar with these terms, refer to a basic Java reference.

One of the main uses for an ExternalType part is to create arrays of function pointers for event handling. EGL text reports use ExternalTypes in this way; see EGL text reports.

The ExternalType part can have any of three stereotypes:

ExternalType functions

If the function is marked static, invoke it using the name of the ExternalType part and dot syntax (typeName.methodName()). Otherwise, create a variable that is based on the ExternalType and append the variable name to the name of the method by using dot syntax (externalTypeVariable.methodName()). For more information, see Example.

Serializable ExternalType

If you are mapping an ExternalType part to a Java class that implements the java.io.Serializable interface, the ExternalType part must extend the predefined Serializable ExternalType:
ExternalType CustomDate extends Serializable type JavaObject
{
  packageName="com.mycompany", 
  javaName="CustomDate" 
}

	// functions

end

Serializable ExternalType variables can be saved directly to disk and restored later, if the associated Java class implements the java.io.Serializable interface. ExternalTypes that do not extend the Serializable ExternalType are assumed to be Transient, or unable to be saved directly to disk. If you want to save the information in a non-Serializable ExternalType, you must use a data source.

The following code shows the Serializable ExternalType:
ExternalType Serializable type JavaObject
{
  JavaName = "Serializable", 
  PackageName = "java.io"
}
end

Feedback