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