validateMethod

validateMethod(source:             String;
               schemaType:         Type;
               schema:             Schema;
               errorCode:          Integer output;
               errorPosition:      Integer output;
               errorLength:        Integer output;
               accessErrorMessage: String output) final;

The validateMethod method of the JadeMetadataAnalyzer class validates method source code using user-definable security checks. It calls the compiler to check the syntax of the source code and invokes callbacks to allow you to check the access to each statement and schema entity referenced in the method.

The validateMethod method parameters are listed in the following table.

Parameter Description
source The method source code to be validated.
schemaType The owner type, or owner root type, of the method (that is, the type of the method receiver)
schema The schema against which the method is to be compiled and which is searched when resolving the names of classes referenced in the method.
errorCode The error code returned by the compiler. A value of zero (0) indicates that the method was successfully validated.
errorPosition The position of the error in the source code. Note that the first character of the source code has a position of zero (0).
errorLength The length in characters of the error in the source code.
accessErrorMessage The error message returned by the callback method when the access is not valid.

The method in the following example calls the validateMethod method to validate method source.

checkMethod(source: String; schemaType: Type);
vars
    analyzer      : MyAnalyzer;
    err, pos, len : Integer;
    msg           : String;
begin
    create analyzer;
    analyzer.validateMethod(source, schemaType, currentSchema, err, pos,
                            len, msg);
    if err = 0 then
        write 'method validated successfully';
    else
        write 'method validation failed - ' & process.getErrorText(err);
        if err = JadeMetadataAnalyzer.AccessCheckFailed then
            write msg;
        endif;
    endif;
epilog
    delete analyzer;
end;