1 19 20 package org.netbeans.modules.j2ee.ddloaders.web; 21 22 import javax.xml.parsers.ParserConfigurationException ; 23 import javax.xml.parsers.SAXParser ; 24 import javax.xml.parsers.SAXParserFactory ; 25 import org.openide.filesystems.FileObject; 26 27 import org.netbeans.modules.schema2beans.BaseBean; 28 import org.netbeans.modules.j2ee.dd.api.common.CommonDDBean; 29 import org.netbeans.modules.j2ee.dd.impl.web.WebAppProxy; 30 import org.netbeans.modules.j2ee.dd.api.web.WebApp; 31 import org.netbeans.modules.j2ee.dd.api.web.DDProvider; 32 import java.io.*; 33 import org.xml.sax.*; 34 36 37 41 public class DDUtils { 42 43 private static final String EXCEPTION_PREFIX="version:"; 45 53 public static String findFreeName (CommonDDBean[] elements, String identifier, String name) { 54 if (checkFreeName (elements, identifier, name)) { 55 return name; 56 } 57 for (int i = 1;;i++) { 58 String destName = name + "_"+i; if (checkFreeName (elements, identifier, destName)) { 60 return destName; 61 } 62 } 63 } 64 65 71 private static boolean checkFreeName (CommonDDBean [] elements, String identifier, Object o) { 72 for (int i=0; i<elements.length; i++) { 73 Object val = elements[i].getValue (identifier); 74 if (val != null && val.equals (o)) { 75 return false; 76 } 77 } 78 return true; 79 } 80 81 83 public static BaseBean getBaseBean(CommonDDBean bean) { 84 if (bean instanceof BaseBean) return (BaseBean)bean; 85 else if (bean instanceof WebAppProxy) return (BaseBean) ((WebAppProxy)bean).getOriginal(); 86 return null; 87 } 88 89 } | Popular Tags |