TaglibFunctionSignatureIsValidpublic class TaglibFunctionSignatureIsValid extends com.sun.enterprise.tools.verifier.tests.TagLibTest implements WebCheckThe 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. |
Methods Summary |
---|
public com.sun.enterprise.tools.verifier.Result | check(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 boolean | checkParamTypeClass(java.lang.String[] par, java.lang.ClassLoader cl)return true, if all the parameters specified by par String[] are correctly
specified, false otherwise.
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 void | checkSignature(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
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 boolean | checkValidRType(java.lang.String retType)
boolean valid = true;
try {
Class.forName(retType);
} catch (ClassNotFoundException e) {
return valid=false;
}
return valid;
|
|