script

Syntax

visibility script scriptName(parameters) : returnType {
    body
}

where:


Each parameter is of the form:

name : type

where:

Description

The script statement defines the signature of a script, as well as the contents to be evaluated.

The signature of a script must be unique within its metatype. The signature is defined by the script's name and its number of parameters: two scripts defined on the same metatype can share the same name as long as they have different number of parameters.

The script may define expected parameters, used to compute the returned value. Any caller of the script must provide matching arguments. An MQL script may return any type of object (or may not return anything). You can specify the return type in the script signature.

The self variable is available in the script contents. This variable is the instance the script is evaluated on (instance of the script's metatype).

Examples

This code defines scripts attached to the UML Class type:

package com.mycompany.example;

metatype uml21.Class;

public script qualifiedName() : String {
    return self.namespace.name + "." + self.name;
}

private script anotherScript() : String {
    ...
}

Related concepts
Script