Adding Interface Methods
An interface method consists of a signature only (that is, it contains no method body). When a class implements an interface, the interface methods are implemented by the class as if they were normal JADE methods, although it is your responsibility to provide the required method sources that make the method implementations useful.
When adding methods to an interface:
-
If a new method is added to a currently implemented interface, a new method stub is automatically generated in the implementing classes, as shown in the following image. (For details, see "Implementing an Interface", later in this chapter.)
If you did not specify that you require a reminder that generated methods are purely a shell without any code and that you have not yet provided the appropriate method implementation details, the new class method is generated with the text block at the beginning of the stub method body commented out, as shown in the following image.
If you want a compile-time error generated when the stub method is created (that is, it is marked in error in the Methods List of the Class Browser), check the check box in the Interface Options group box on the Miscellaneous sheet of the Preferences dialog. (For details, see "Maintaining Miscellaneous Options", in Chapter 2.) Stub methods are then automatically generated with body details that you must comment out or remove before the method compiles, as a way of highlighting that you have yet to provide the required method body. For example, you can locate these empty methods by displaying methods in error, to find the methods that you are likely to want to flesh out to make the implementation useful.
To compile the method, delete or comment out the text line.
-
You can view current mappings of a selected method. For details, see "Viewing Current Interface Mappings", later in this chapter.
-
Interface methods do not provide any implementation details. A compile-time error is raised if the method contains body details.
For details about obtaining bubble help (for example, to locate and insert the required constant or property for the interface), see "Using Bubble Help in the Editor Pane", in Chapter 4.
Before you define a method, you must select the interface to which the method is to be added.
To add a method to an interface
-
In the Interface List of the Interface Browser, click on the interface for which the method is to be added.
-
Select the New JADE Method command from the Methods menu.
The JADE Method Definition dialog, shown in the following image, is then displayed.
As interface methods can contain only a method signature, controls that do not apply to interface methods are disabled.
-
Specify the name of your new method in the Name text box. The name value must start with a lowercase character and the name must be unique to the interface to which it is being added.
-
Click the Enter Text button if you want to specify or maintain descriptive text for the JADE method as part of the definition or maintenance of the method. For details, see "Specifying Text for a Schema Element", in Chapter 3.
You can also specify descriptive text for the JADE method 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.
The method signature is then displayed in the editor pane of the Interface Browser.