1 56 package org.objectstyle.cayenne.project.validator; 57 58 import java.util.Iterator ; 59 60 import org.objectstyle.cayenne.access.DataDomain; 61 import org.objectstyle.cayenne.project.Project; 62 import org.objectstyle.cayenne.project.ProjectPath; 63 import org.objectstyle.cayenne.util.Util; 64 65 68 public class DomainValidator extends TreeNodeValidator { 69 72 public DomainValidator() { 73 super(); 74 } 75 76 public void validateObject(ProjectPath path, Validator validator) { 77 78 DataDomain domain = (DataDomain) path.getObject(); 80 String name = domain.getName(); 81 if (Util.isEmptyString(name)) { 82 validator.registerError("Unnamed DataDomain.", path); 83 84 return; 86 } 87 88 Project project = (Project) path.getObjectParent(); 89 if (project == null) { 90 return; 91 } 92 93 Iterator it = project.getChildren().iterator(); 95 while (it.hasNext()) { 96 DataDomain dom = (DataDomain) it.next(); 97 if (dom == domain) { 98 continue; 99 } 100 101 if (name.equals(dom.getName())) { 102 validator.registerError("Duplicate DataDomain name: " + name + ".", path); 103 return; 104 } 105 } 106 } 107 } 108 | Popular Tags |