1 19 20 26 27 package org.netbeans.modules.web.dd.impl.common; 28 29 import org.netbeans.modules.schema2beans.Version; 30 import org.netbeans.modules.schema2beans.BaseBean; 31 import org.netbeans.api.web.dd.common.*; 32 import org.netbeans.api.web.dd.WebApp; 33 34 public abstract class EnclosingBean extends BaseBean implements CommonDDBean, CreateCapability, FindCapability { 35 36 37 public EnclosingBean(java.util.Vector comps, Version version) { 38 super(comps, version); 39 } 40 41 49 public CommonDDBean findBeanByName(String beanName, String propertyName, String value) { 50 return (CommonDDBean)CommonDDAccess.findBeanByName(this, beanName, propertyName, value); 51 } 52 53 59 public CommonDDBean createBean(String beanName) throws ClassNotFoundException { 60 return (CommonDDBean)CommonDDAccess.newBean(this, beanName, getPackagePostfix ()); 61 } 62 63 private String getPackagePostfix () { 64 String pack = getClass().getPackage().getName(); 65 if (pack.endsWith(CommonDDAccess.SERVLET_2_4)) return CommonDDAccess.SERVLET_2_4; 66 else return CommonDDAccess.SERVLET_2_3; 67 } 68 69 public void write (org.openide.filesystems.FileObject fo) throws java.io.IOException { 70 } 73 74 public CommonDDBean addBean(String beanName, String [] propertyNames, Object [] propertyValues, String keyProperty) throws ClassNotFoundException , NameAlreadyUsedException { 75 if (keyProperty!=null) { 76 Object keyValue = null; 77 if (propertyNames!=null) 78 for (int i=0;i<propertyNames.length;i++) { 79 if (keyProperty.equals(propertyNames[i])) { 80 keyValue=propertyValues[i]; 81 break; 82 } 83 } 84 if (keyValue!=null && keyValue instanceof String ) { 85 if (findBeanByName(beanName, keyProperty,(String )keyValue)!=null) { 86 throw new NameAlreadyUsedException(beanName, keyProperty, (String )keyValue); 87 } 88 } 89 } 90 CommonDDBean newBean = createBean(beanName); 91 if (propertyNames!=null) 92 for (int i=0;i<propertyNames.length;i++) { 93 try { 94 ((BaseBean)newBean).setValue(propertyNames[i],propertyValues[i]); 95 } catch (IndexOutOfBoundsException ex) { 96 ((BaseBean)newBean).setValue(propertyNames[i],new Object []{propertyValues[i]}); 97 } 98 } 99 CommonDDAccess.addBean(this, newBean, beanName, getPackagePostfix ()); 100 return newBean; 101 } 102 103 public CommonDDBean addBean(String beanName) throws ClassNotFoundException { 104 try { 105 return addBean(beanName,null,null,null); 106 } catch (NameAlreadyUsedException ex){} 107 return null; 108 } 109 110 public void merge(RootInterface root, int mode) { 111 this.merge((BaseBean)root,mode); 112 } 113 114 } 115 | Popular Tags |