METHOD PRIVATE PROTECTED PUBLIC STATIC ABSTRACTOVERRIDE FINALVOID return-type method-name( parameter , parameter ) :method-body
METHOD PUBLICVOID return-type method-name( parameter , parameter ) .
METHOD PROTECTED PUBLIC OVERRIDE ABSTRACTVOID return-type method-name( parameter , parameter ) .PRIVATE PROTECTED PUBLIC
PUBLIC matches the .NET public access levelSTATICFor more information on the mechanism for calling methods of different access modes and scopes, see the reference entry for Class-based property access.ABSTRACTOVERRIDE
Note: A .NET abstract class is defined in C# with the abstract keyword.Note that instance methods do not override static methods and static methods do not redefine instance methods. For more information about overriding and redefining methods, see OpenEdge Development: Object-oriented Programming.
FINALIndicates the data type of the method return value. You can specify return-type as one of the following data types. For more information on each data type, see the Data types reference entry:
CHARACTER COM-HANDLE DATE DATETIME DATETIME-TZ DECIMALHANDLE INT64 INTEGER LOGICAL LONGCHAR MEMPTR RAWRECID ROWID AS-data-typeCLASS object-type-name EXTENT constantIf you are defining the return type for a method that overrides a .NET super class method (abstract or otherwise) or implements a method defined in a .NET interface, return-type must specify the exact return type of the overridden or implemented .NET method. For a .NET mapped data type that is a default match for an ABL primitive type, you must use the default matching ABL data type, as shown in Table 24. (For example, INTEGER indicates a .NET System.Int32.) For a .NET mapped data type that is not a default match for one of the ABL primitive types, ABL provides a data type keyword (the AS-data-type) that you must use to explicitly indicate the required .NET data type, as shown in Table 25. (For example, UNSIGNED-BYTE indicates a .NET System.Byte.)
Note: At run time, a method return type defined using an AS-data-type keyword behaves in ABL like the corresponding ABL primitive type shown in Table 25. (For example, an UNSIGNED-BYTE behaves like an INTEGER.)Also note that when overriding or implementing a .NET array return value, you must specify the .NET array object type (for example, "System.Int32[]" or "System.Byte[]"); you cannot use an ABL array equivalent (for example, INTEGER EXTENT or UNSIGNED-BYTE EXTENT).Specifies the type name of an ABL or .NET class or interface. Specify an object type name using the syntax described in the Type-name syntax reference entry. With an appropriate USING statement, you can also specify a class or interface name alone, without the qualifying package or namespace.If you are defining the return type for a method that overrides a .NET super class method (abstract or otherwise), or that implements a method defined in a .NET interface, object-type-name must specify the exact return type of the overridden or implemented .NET method. However, for .NET inner (nested) type, note the difference in the ABL syntax, which replaces the corresponding period (.) in the .NET object type with a plus (+) (see the Type-name syntax reference entry).Also note that when overriding or implementing a .NET array return value, you must specify the .NET array object type (for example, "System.Drawing.Point[]"); you cannot use an ABL array equivalent (such as System.Drawing.Point EXTENT).CLASSFor a class or interface return value, ABL returns an object reference associated with the class or interface, not a class instance itself. For more information on object references, see the Class-based object reference reference entry.constantEXTENTDefines the return value as an array of data elements with a primitive or object data type. This option can specify an array return value as either determinate (has a defined number of elements) or indeterminate (has an undefined number of elements). To define a determinate array return value, specify the EXTENT option with the constant argument. This optional argument is an integer value that represents the number of elements in the array. To define an indeterminate array return value, specify the EXTENT option without the constant argument.If you do not use the EXTENT option (or you specify constant as 0), the return value is not an array return value.If the method implements a .NET interface method prototype or overrides an inherited .NET method (abstract or otherwise), you must explicitly map any .NET mapped types specified for parameters of the .NET method (see Table 25). Note that at run time, any explicitly mapped parameter behaves like the corresponding ABL primitive type.For more information on the syntax of parameter, establishing uniqueness for method overloading, and on mapping .NET parameter types, see the Parameter definition syntax reference entry.The body for a method implementation. For an interface method prototype or an abstract method, you cannot specify method-body. For more information about declaring method prototypes in an interface, see the INTERFACE statement reference entry.Define method-body using the following syntax:
method-logic
...catch-block catch-blockfinally-blockEND METHOD .If you define the method to return a value of the data type specified by return-type, you can execute the RETURN statement to set a value of that data type to return at run time. If return-type is defined as a .NET array of mapped types (for example, "System.Byte[]"), you must return an object reference of the specified .NET array of mapped types in the RETURN statement. You cannot return an ABL array of a type that maps to the .NET array type (for example, INTEGER EXTENT) or the AVM raises a run-time error. If you do not execute any RETURN statement for return-type in the method-logic, the method returns the Unknown value (?) as its return value.Specifies a CATCH statement that defines error handling code for one or more error types. A DO block does not have any default error handling. Therefore, a DO block must have error handling options specified such that it becomes an undo-able block. Otherwise, ABL generates a compiler warning. For more information on catch-block, see the CATCH statement reference entry.Specifies a FINALLY statement that defines the processing that must occur after all other processing in the block occurs. For more information on finally-block, see the FINALLY statement reference entry.END METHOD
INTERFACE acme.myObjs.Interfaces.ICustObj:METHOD PUBLIC CHARACTER GetCustomerName (INPUT inCustNum AS INTEGER).
END INTERFACE.For more examples of method definitions, including static and abstract methods, see the descriptions of r-CustObj.cls, r-CustObjStatic.cls, and r-CustObjAbstract.cls in the CLASS statement reference entry.
A method of a class can invoke another method of a class (instance or static, as appropriate), as well as an internal or external procedure or a user-defined function. Similarly, a procedure or user-defined function can invoke a method of a class. Note that if method-name is an ABL reserved keyword, you might need to use the THIS-OBJECT system reference or Type-name syntax to call the method. For more information on referencing and invoking methods, see the reference entry for a Class-based method call.
When defining local variables and other data elements for any method, even one that overrides or implements a .NET method, you cannot define these elements using an AS data type (see Table 25). You must use an ABL data type like any other method definition. The ABL data that you assign to or from a given .NET method parameter must be assignment compatible with the .NET type, as in all other contexts.
You can handle application errors in a method as in any ABL block. By executing a RETURN ERROR action at the block level or a THROW action at the block level with the presence of a ROUTINE-LEVEL ON ERROR UNDO, THROW statement, the AVM returns the ERROR condition to the statement that invoked the method. If a RETURN ERROR also includes the option to return a character string value, or you set the ReturnValue property of a Progess.Lang.AppError object that you THROW, you can get this value using the RETURN-VALUE function following the statement that invoked the method or in a CATCH block that catches the Progress.Lang.AppError object. For more information, see OpenEdge Development: Object-oriented Programming.
You cannot override an inherited .NET generic method. However, you can create a non-generic ABL method of the same name (without a type parameter list).
You cannot override the following .NET methods:In .NET, these methods are overridable. However, OpenEdge defines these methods as FINAL for an ABL session. Instead of overriding .NET methods (such as Dispose( )) that destroy or otherwise clean-up .NET resources, always use a destructor in the ABL class to manage class clean-up using these methods, even when inheriting from a .NET class. Similarly, if you want to return an ABL-processed value generated by GetHashCode( ), create a separate ABL method that calls GetHashCode( ) to return the value.
When you define a method in an ABL class that inherits a .NET class, you cannot define method-name as any of the following reserved method names (case insensitive) or ABL raises a compile-time error:
Get_property-name( ) — Where property-name is the name of a property (including any default indexed property) defined by the .NET super class
Note:
Set_property-name( ) — Where property-name is the name of a property (including any default indexed property) defined by the .NET super class
When you raise error from within an ABL method that overrides a .NET method or implements a .NET method defined in a .NET interface, if the method is called from .NET, and ABL error options raise the error out of the method block, ABL returns a .NET System.Exception to the caller. If the error is raised by executing a RETURN ERROR with the optional error string, the Message property of the System.Exception describes the operation where the error occurred, but the error string is available only to the ABL session, using the RETURN-VALUE function. If the error is raised by executing a RETURN ERROR with an optional ABL error object or by executing an UNDO, THROW, the System.Exception:Message property includes both a description of the operation where the error occurred and any messages from the ABL error object. If the error is fatal, the AVM responds as for any ABL class, generating a protrace file and exiting the session.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |