KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > validator > WSDLSemanticValidator


1 package org.netbeans.modules.xml.wsdl.validator;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Collections JavaDoc;
5 import java.util.List JavaDoc;
6 import java.util.Vector JavaDoc;
7
8 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
9 import org.netbeans.modules.xml.wsdl.validator.visitor.WSDLSemanticsVisitor;
10 import org.netbeans.modules.xml.xam.Model;
11 import org.netbeans.modules.xml.xam.spi.Validation;
12 import org.netbeans.modules.xml.xam.spi.ValidationResult;
13 import org.netbeans.modules.xml.xam.spi.Validator;
14 import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
15
16 public class WSDLSemanticValidator implements Validator {
17     
18     @SuppressWarnings JavaDoc("unchecked")
19     public static final ValidationResult EMPTY_RESULT =
20         new ValidationResult( Collections.EMPTY_SET, Collections.EMPTY_SET);
21     
22     public String JavaDoc getName() {
23         return "WSDLSemanticValidator"; //NO I18N
24
}
25     
26     public ValidationResult validate(Model model, Validation validation, ValidationType validationType) {
27         if (model instanceof WSDLModel) {
28             WSDLModel wsdlModel = (WSDLModel) model;
29
30             List JavaDoc<Model> validatedModels = new ArrayList JavaDoc<Model>();
31             if (validationType.equals(ValidationType.COMPLETE) ||
32                     validationType.equals(ValidationType.PARTIAL)) {
33                 if ( wsdlModel.getState() == Model.State.NOT_WELL_FORMED ){
34                     return EMPTY_RESULT;
35                 }
36                  
37                 WSDLSemanticsVisitor visitor = new WSDLSemanticsVisitor(this, validation, validatedModels);
38                 wsdlModel.getDefinitions().accept(visitor);
39                 validatedModels.add(model);
40                 List JavaDoc<ResultItem> resultItems = visitor.getResultItems();
41                 return new ValidationResult(resultItems, validatedModels);
42                 
43             }
44         }
45         return EMPTY_RESULT;
46     }
47     
48 }
49
Popular Tags