A conditional expression is a restricted form of a method. The major use of a condition is as a constraint, which is used to maintain automatic inverse references when a specified condition is satisfied. When defining conditions, note the following.
You can specify constraints only on automatic inverse references and not on manual or manual/automatic inverse references.
When the manual side of the inverse reference is set, the condition used as the constraint is evaluated and the automatic inverse is set only if the condition is true. If the automatic reference is a
A condition used as a constraint cannot have parameters.
You cannot reimplement conditions defined in superschemas or superclasses.
You can add a condition only to Instance methods.
Only
For examples of conditions and constraints, see "Condition Examples", in the following subsection.
Before you define a new condition, you must select the class or primitive type to which the method is to be added.
Conditions cannot involve reference properties.
To add a condition to a class or primitive type
In the Class List of the Class Browser or the Primitive Types List of the Primitive Types Browser, click on the class or primitive type for which the condition is to be added.
Select the New Condition command from the Methods menu. (This command is enabled only when the All or Instance sheet has focus.)
The Add Condition dialog is then displayed.
Specify the name of your new condition in the Name text box. The name value must start with a lowercase character and the name must be unique to the class or primitive type to which it is being added.
Check the Protected check box if you want the
By default, conditions are not protected.
A padlock symbol is not displayed to the left of the condition name in the browser Methods List. To determine if an existing condition is protected, select the condition in the Methods List and see whether the protected option is displayed in the condition signature in the editor pane.
Check the Subschema Hidden check box if you want to specify that the condition is available only in the local schema; that is, it is not available for use in any subschemas. For details, see "subschemaHidden Option" under "Controlling the Use of Elements in Other Schemas", in Chapter 1.
Click the Enter Text button if you want to specify or maintain descriptive text for the condition as part of the definition or maintenance of the condition. For details, see "Specifying Text for a Schema Element", in Chapter 3.
You can also specify descriptive text for the condition at any time, by selecting the Text command from the Methods menu. For details, see "Using the Free-Standing Editor Window to Define Text", in Chapter 3.
Click the OK button or the Next button.
A template for the condition is then displayed in the editor pane of the browser window.
The error symbol is displayed to the left of the condition name in the Methods List until you have specified any parameters that you require and the boolean-expression return value for the condition, and then compiled it.
If a method template has been defined for all new methods and conditions in your JADE development database or for your own JADE methods and conditions, the defined method template is displayed in the editor pane. For details, see "Maintaining Text Templates", in Chapter 2.
A condition has the following syntax.
condition-name([parameters]): Boolean condition; [constants constant-declarations] begin condition-instructions; end;
Only
This syntax (with the exception of the optional parameters and constant-declarations) is automatically displayed with the return instruction in the editor pane when you click the OK button in the Add Condition dialog unless a method template is defined for your JADE development environment, in which case the editor pane display is determined by the template.
A condition cannot use array indexing ([index]) or dictionary indexing ([key, key, ...]).
You can define optional parameters only for conditions that are not constraints, and the parameters must be constant values. For more details, see "
Modify the template by specifying the boolean expression that you require following the
When you have specified the boolean expression to return or the if condition and any constant parameters that you require for a condition that is not a constraint, compile the condition. (For details, see "Compiling Methods", later in this section.)
When you have compiled the condition, the condition symbol is then displayed to the left of the condition name in the Methods List.
The following image shows an example of a condition.