1 19 20 package org.netbeans.modules.j2ee.ddloaders.ejb; 21 22 import org.netbeans.modules.schema2beans.BaseBean; 23 import org.netbeans.modules.j2ee.dd.api.common.CommonDDBean; 24 import org.netbeans.modules.j2ee.dd.impl.ejb.EjbJarProxy; 25 26 27 31 public class EjbJarDDUtils { 32 private EjbJarDDUtils() {} 33 34 41 public static String findFreeName (CommonDDBean[] elements, String identifier, String name) { 42 if (checkFreeName (elements, identifier, name)) { 43 return name; 44 } 45 for (int i = 1;;i++) { 46 String destName = name + "_"+i; if (checkFreeName (elements, identifier, destName)) { 48 return destName; 49 } 50 } 51 } 52 53 59 private static boolean checkFreeName (CommonDDBean [] elements, String identifier, Object o) { 60 for (int i=0; i<elements.length; i++) { 61 Object val = elements[i].getValue (identifier); 62 if (val != null && val.equals (o)) { 63 return false; 64 } 65 } 66 return true; 67 } 68 69 71 public static BaseBean getBaseBean(CommonDDBean bean) { 72 if (bean instanceof BaseBean) return (BaseBean)bean; 73 else if (bean instanceof EjbJarProxy) return (BaseBean) ((EjbJarProxy)bean).getOriginal(); 74 return null; 75 } 76 } 77 | Popular Tags |