TagNameIsUniquepublic class TagNameIsUnique extends WebTest implements WebCheckThe name of tag must be unique. |
Fields Summary |
---|
boolean | oneFailed |
Methods Summary |
---|
public com.sun.enterprise.tools.verifier.Result | check(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
Context context = getVerifierContext();
Result result = loadWarFile(descriptor);
TagLibDescriptor tlds[] = context.getTagLibDescriptors();
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) {
TagDescriptor[] tagDesc = tld.getTagDescriptors();
List<String> name = new ArrayList<String>();
for(TagDescriptor td : tagDesc) {
name.add(td.getTagName());
}
if (name != null) {
String[] names = (String[])name.toArray(new String[0]);
if (!checkForDuplicateNames(result, compName, names, tld)) {
addGoodDetails(result, compName);
result.addGoodDetails(smh.getLocalString
(getClass().getName() + ".passed1",
"All 'name' elements are defined properly under tag element of [ {0} ]",
new Object[]{tld.getUri()}));
}
}
}
if(oneFailed){
result.setStatus(Result.FAILED);
} else {
result.setStatus(Result.PASSED);
}
return result;
| public boolean | checkForDuplicateNames(com.sun.enterprise.tools.verifier.Result result, com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor compName, java.lang.String[] names, com.sun.enterprise.tools.verifier.TagLibDescriptor tld)
boolean duplicate = false;
for(int i=0; i<names.length-1;i++){
for (int j=i+1; j<names.length; j++) {
duplicate = names[i].trim().equals(names[j]);
if(duplicate) {
oneFailed=true;
addErrorDetails(result, compName);
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"The name element value [ {0} ] under tag " +
"element in [ {1} ] is not unique",
new Object[] {names[i], tld.getUri()}));
}
}
}
return oneFailed;
|
|