FileDocCategorySizeDatePackage
TaglibFunctionSignatureIsValid.javaAPI DocGlassfish v2 API6581Fri May 04 22:34:10 BST 2007com.sun.enterprise.tools.verifier.tests.web

TaglibFunctionSignatureIsValid

public class TaglibFunctionSignatureIsValid extends com.sun.enterprise.tools.verifier.tests.TagLibTest implements WebCheck
The function-signature must be specified using a fully-qualified return type followed by the method name, followed by the fully-qualified argument types in parenthesis, separated by commas.
author
Sudipto Ghosh

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)

        ComponentNameConstructor compName =
                getVerifierContext().getComponentNameConstructor();
        Result result = getInitializedResult();
        Context context = getVerifierContext();
        TagLibDescriptor tlds[] = context.getTagLibDescriptors();
        FunctionDescriptor[] fnDesc = null;

        if (tlds == null) {
            addGoodDetails(result, compName);
            result.passed(smh.getLocalString
                    (getClass().getName() + ".passed",
                            "No tag lib files are specified"));
            return result;
        }

        for (TagLibDescriptor tld : tlds) {
            if (tld.getSpecVersion().compareTo("2.0") >= 0) {
                fnDesc = tld.getFunctionDescriptors();
                if (fnDesc != null)
                    for (FunctionDescriptor fd : fnDesc)
                        checkSignature(result, fd, tld, compName);
            }
        }
        if (result.getStatus() != Result.FAILED) {
            addGoodDetails(result, compName);
            result.passed(smh.getLocalString(getClass()
                    .getName() +
                    ".passed", "function-signature element of the tag lib " +
                    "descriptor are properly defined."));
        }
        return result;
    
private booleancheckParamTypeClass(java.lang.String[] par, java.lang.ClassLoader cl)
return true, if all the parameters specified by par String[] are correctly specified, false otherwise.

param
par
param
cl
return

        for(String s : par) {
            Class c = checkIfPrimitive(s);
            if (c == null)
                try {
                    c = Class.forName(s, false, cl);
                } catch (ClassNotFoundException e) {
                    return false;
                }
        }
        return true;
    
private voidcheckSignature(com.sun.enterprise.tools.verifier.Result result, com.sun.enterprise.tools.verifier.web.FunctionDescriptor fnDesc, com.sun.enterprise.tools.verifier.TagLibDescriptor tld, com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor compName)
Checks the validity of the signature string contained in function-signature object

param
result
param
fnDesc
param
tld
param
compName

        String signature = fnDesc.getFunctionSignature();
        ClassLoader cl = getVerifierContext().getClassLoader();
        String retType = getRetType(signature);
        String[] parameter = getParameters(signature);
        if (checkIfPrimitive(retType) == null && !checkValidRType(retType)) {
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName() +
                    ".failed",
                    "ERROR: In the tld [ {0} ] return type is not specified correctly in " +
                    "this signature [ {1} ]",
                     new Object[]{tld.getUri(), signature}));
        }
        //parameter is a basic type or fully qualified Type
        if(!checkParamTypeClass(parameter, cl)) {
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString(getClass().getName() +
                    ".failed1",
                    "ERROR: In the tld [ {0} ] parameters are not specified correctly in " +
                    "this signature [ {1} ]",
                     new Object[]{tld.getUri(), signature}));
        }
    
private booleancheckValidRType(java.lang.String retType)

param
retType
return
true if the return type is specified correctly, false otherwise

        boolean valid = true;
        try {
            Class.forName(retType);
        } catch (ClassNotFoundException e) {
             return valid=false;
        }
        return valid;