1 package org.netbeans.modules.xml.wsdl.validator; 2 3 import java.util.ArrayList ; 4 import java.util.Collections ; 5 import java.util.List ; 6 import java.util.Vector ; 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 ("unchecked") 19 public static final ValidationResult EMPTY_RESULT = 20 new ValidationResult( Collections.EMPTY_SET, Collections.EMPTY_SET); 21 22 public String getName() { 23 return "WSDLSemanticValidator"; } 25 26 public ValidationResult validate(Model model, Validation validation, ValidationType validationType) { 27 if (model instanceof WSDLModel) { 28 WSDLModel wsdlModel = (WSDLModel) model; 29 30 List <Model> validatedModels = new ArrayList <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 <ResultItem> resultItems = visitor.getResultItems(); 41 return new ValidationResult(resultItems, validatedModels); 42 43 } 44 } 45 return EMPTY_RESULT; 46 } 47 48 } 49 | Popular Tags |