Type Methods

Type methods provide a way of calling a method declared on a type (class, primitive, or interface) without having to have an instance of the type. While the method is declared on a type and has the same scope as an instance method, at run time the receiver is the type on which the method is declared; not an instance of the type.

Type methods enable you to define and call methods on class, primitive, or interface types without having to instantiate a dummy object, which simplifies aspects of JADE application development. Examples of a type method are a:

A type method is identified by the typeMethod method option on the method declaration; for example:

demoTypeMethod() typeMethod;
vars
begin
end;

As the receiver is not an instance of the type, you cannot use the self system variable in a type method, but you can use the selfType system variable, which references the type. You can use the selfType system variable in both type methods and existing class instance methods.

Two syntaxes are supported for calling a type method. To avoid overloading the dot operator (.) notation, the @ operator identifies that a type method is being called.

See also "Invoking a Type Method", in the following subsection.

The Jade Method Definition dialog or the External Method Definition dialog contains the Type Method check box, which is unchecked by default. You can declare an existing method as a type method, by adding the typeMethod method option to the method signature and then recompiling the method. (Conversely, convert a type method to a class (instance) method, by removing the typeMethod modifier, removing any selfType system variable or changing the selfType system variable to self, and then recompiling the method.)

The Methods List of browser windows has three folders: All, Instance, and Type. By default, the All folder is displayed; that is, all instance methods and all type methods are displayed. By default, instance methods are displayed in a black font and type methods are displayed in a dark blue font in the Methods List of browser windows.

You can reimplement type methods on subclasses. As is the case for instance methods, the signature must be the same in all implementations. At run time, the value of the variable is used to determine which implementation of demoTypeMethod will be called. If the value of the variable is an instance of a subclass and a type method reimplements a type method on the class, the reimplemented type method will be called. If the value of the variable is null, the type method on the declared type of the variable is called.

Transient type methods (created by the Process class createTransientMethod method) are supported.

JADE implements the following Application Programming Interfaces (APIs) to call a type method on a class and primitive type. The jomSendTypeMsg API call sends a message to the type of the receiver, and the jomCallPrimTypeMethod API call invokes a primitive type; for example, from an external method. For more details, see "JADE Application Programming Interface (API)", in Chapter 3 of the JADE Object Manager Guide.

A type method can... A type method cannot...

Be a JADE method or an external method.

Use self or any instance methods or properties.

Be defined on a JADE class, a primitive type (for example, Integer), or an interface type.

Be a constructor or a destructor.

Be used with the public, updating, protected, serverExecution, and clientExecution method options.

Be a notification or an event method.

Reimplement a type method with the same signature defined on a superclass but it cannot reimplement an instance method (and the reverse).

Be a condition.

Invoke its superclass implementation using the JADE inheritMethod instruction or the C++ jomInheritMethod API. Be combined with the lockReceiver, updating, mapping, or webService method option.
Be declared on a subschema copy class, with the usual JADE method visibility applying (that is, a subschema copy method cannot be accessed by applications running in a superschema or a peer schema if the root type or a subschema copy for the class already exists in the schema or a superschema). Reimplement a method defined on a subschema copy class in a superschema or on the root class if the type method is defined on a subschema copy class.
Be imported from a package. Be conditionSafe.
Be defined on an imported class. Be used in a unitTest method.
  Be called from a REST service.