1 package org.objectweb.celtix.tools.processors.wsdl2.validators; 2 3 import java.util.List ; 4 import java.util.Vector ; 5 6 import javax.wsdl.Definition; 7 8 import org.w3c.dom.Node ; 9 10 import org.objectweb.celtix.tools.common.ProcessorEnvironment; 11 import org.objectweb.celtix.tools.common.ToolException; 12 import org.objectweb.celtix.tools.common.WSDLConstants; 13 import org.objectweb.celtix.tools.utils.ElementLocator; 14 15 public abstract class AbstractValidator { 16 protected List <String > errorMessages = new Vector <String >(); 17 protected Definition def; 18 protected ProcessorEnvironment env; 19 20 public AbstractValidator(Definition definition) { 21 this.def = definition; 22 } 23 24 public AbstractValidator(String schemaDir) throws ToolException { 25 } 26 27 public AbstractValidator(Definition definition, ProcessorEnvironment pEnv) { 28 this.def = definition; 29 this.env = pEnv; 30 } 31 32 public abstract boolean isValid(); 33 34 public void addErrorMessage(String err) { 35 errorMessages.add(err); 36 } 37 38 public String getErrorMessage() { 39 StringBuffer strbuffer = new StringBuffer (); 40 for (int i = 0; i < errorMessages.size(); i++) { 41 strbuffer.append(errorMessages.get(i)); 42 strbuffer.append(System.getProperty("line.separator")); 43 } 44 return strbuffer.toString(); 45 } 46 47 public void addError(Node node, String msg) { 48 ElementLocator locator = (ElementLocator)node.getUserData(WSDLConstants.NODE_LOCATION); 49 String errMsg = "line " + locator.getLine() + " column " + locator.getColumn(); 50 errMsg = errMsg + " of " + def.getDocumentBaseURI() + " " + msg; 51 addErrorMessage(errMsg); 52 } 53 } 54 | Popular Tags |