1 19 package org.netbeans.modules.j2ee.websphere6.dd.beans; 20 21 import org.w3c.dom.*; 22 import org.netbeans.modules.schema2beans.*; 23 import java.beans.*; 24 import java.util.*; 25 import java.io.*; 26 27 31 public class WSEjbExt extends DDXmi{ 32 private static final String ROOT=TYPE_EJB_EXT_ID; 33 34 private static final String ROOT_NAME="EjbJarExt"; 35 36 37 public WSEjbExt() { 38 this(null, Common.USE_DEFAULT_VALUES); 39 } 40 public WSEjbExt(org.w3c.dom.Node doc, int options) { 41 this(Common.NO_DEFAULT_VALUES); 42 try { 43 initFromNode(doc, options); 44 } catch (Schema2BeansException e) { 45 throw new RuntimeException (e); 46 } 47 } 48 public WSEjbExt(File f,boolean validate) throws IOException{ 49 this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES); 50 } 51 52 public WSEjbExt(InputStream in, boolean validate) { 53 this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES); 54 } 55 56 protected void initFromNode(org.w3c.dom.Node doc, int options) throws Schema2BeansException { 57 if (doc == null) { 58 doc = GraphManager.createRootElementNode(ROOT); if (doc == null) 60 throw new Schema2BeansException(Common.getMessage( 61 "CantCreateDOMRoot_msg", ROOT)); 62 } 63 Node n = GraphManager.getElementNode(ROOT, doc); if (n == null) { 65 throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName())); 66 } 67 this.graphManager.setXmlDocument(doc); 68 this.createBean(n, this.graphManager()); 69 this.initialize(options); 70 }; 71 public WSEjbExt(int options) { 72 super(options,ROOT); 73 } 74 public void initialize(int options) { 75 76 } 77 78 public void setDefaults() { 79 setXmiVersion(); 80 setNsXmi(); 81 setNsEjbExt(); 82 setNsEjb(); 83 setXmiId("EJBJarExtension"); 84 setNsCommonextLocaltran(); 85 setEjbJar(""); 86 setEjbJarHref("ID_ejb_jar"); 87 } 88 89 protected void initOptions(int options) { 90 this.graphManager = new GraphManager(this); 91 this.createRoot(ROOT, ROOT_NAME, Common.TYPE_1 | Common.TYPE_BEAN, WSEjbExt.class); 93 94 initPropertyTables(2); 95 this.createAttribute(XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 96 this.createAttribute(NS_EJB_ID, NS_EJB, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 97 this.createAttribute(NS_EJB_EXT_ID, NS_EJB_EXT, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 98 this.createAttribute(NS_XMI_ID, NS_XMI, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 99 this.createAttribute(XMI_VERSION_ID, XMI_VERSION, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 100 this.createAttribute(NS_COMMONEXT_LOCALTRAN_ID,NS_COMMONEXT_LOCALTRAN, AttrProp.CDATA | AttrProp.IMPLIED,null, null); 101 102 103 this.createProperty(EJB_EXTENSIONS_ID, 104 EJB_EXTENSIONS, 105 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 106 EjbExtensionsType.class); 107 this.createAttribute(EJB_EXTENSIONS,XMI_TYPE_ID , EJB_EXTENSIONS_XMI_TYPE , AttrProp.CDATA | AttrProp.IMPLIED,null, null); 108 this.createAttribute(EJB_EXTENSIONS,XMI_ID_ID , EJB_EXTENSIONS_XMI_ID , AttrProp.CDATA | AttrProp.IMPLIED,null, null); 109 this.createAttribute(EJB_EXTENSIONS,NAME_ID , EJB_EXTENSIONS_XMI_NAME , AttrProp.CDATA | AttrProp.IMPLIED,null, null); 110 111 this.createProperty(EJB_JAR_ID, EJB_JAR, 113 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 114 java.lang.String .class); 115 this.createAttribute(EJB_JAR,HREF_ID,EJB_JAR_HREF,AttrProp.CDATA | AttrProp.IMPLIED,null, null); 116 this.initialize(options); 117 } 118 119 public void setEjbExtensions(int index,EjbExtensionsType value) { 120 this.setValue(EJB_EXTENSIONS, index,value); 121 } 122 123 public void setEjbExtensions(EjbExtensionsType[]value) { 124 this.setValue(EJB_EXTENSIONS, value); 125 } 126 public EjbExtensionsType[] getEjbExtensions() { 128 return (EjbExtensionsType[])this.getValues(EJB_EXTENSIONS); 129 } 130 public EjbExtensionsType getEjbExtensions(int index) { 131 return (EjbExtensionsType)this.getValue(EJB_EXTENSIONS,index); 132 } 133 public int sizeEjbExtensions() { 134 return this.size(EJB_EXTENSIONS); 135 } 136 public int addEjbExtensions(EjbExtensionsType value) { 137 int positionOfNewItem = this.addValue(EJB_EXTENSIONS, value); 138 return positionOfNewItem; 139 } 140 141 public int removeEjbExtensions(EjbExtensionsType value) { 146 return this.removeValue(EJB_EXTENSIONS, value); 147 } 148 149 150 151 152 153 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 154 155 if (getEjbExtensions()!= null) { 156 for (int _index = 0; _index < sizeEjbExtensions(); ++_index) { 158 EjbExtensionsType element = getEjbExtensions(_index); 159 if (element != null) { 160 element.validate(); 161 } 162 163 } 164 } 165 if (getEjbJar()== null) { 166 throw new org.netbeans.modules.schema2beans.ValidateException("getEjbJar() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, EJB_JAR, this); } 168 if (getEjbJarHref()==null) { 169 throw new org.netbeans.modules.schema2beans.ValidateException("getEjbJarHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, EJB_JAR, this); } 171 if (getNsEjb()==null) { 172 throw new org.netbeans.modules.schema2beans.ValidateException("getNsEjb() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 174 if (getNsEjbExt()==null) { 175 throw new org.netbeans.modules.schema2beans.ValidateException("getNsEjbExt() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 177 if (getNsXmi()==null) { 178 throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 180 if(getXmiId()==null) { 181 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 183 if(getXmiVersion()==null) { 184 throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); } 186 187 } 188 189 public void dump(StringBuffer str, String indent){ 190 String s; 191 Object o; 192 BaseBean n; 193 194 str.append(indent); 195 str.append(EJB_JAR); str.append(indent+"\t"); str.append("<"); o = this.getApplication(); 199 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(EJB_JAR, 0, str, indent); 202 203 str.append(indent); 204 str.append(EJB_EXTENSIONS+"["+this.sizeEjbExtensions()+"]"); for(int i=0; i<this.sizeEjbExtensions(); i++) { 206 str.append(indent+"\t"); 207 str.append("#"+i+":"); 208 n = (BaseBean) this.getEjbExtensions(i); 209 if (n != null) 210 n.dump(str, indent + "\t"); else 212 str.append(indent+"\tnull"); this.dumpAttributes(EJB_EXTENSIONS, i, str, indent); 214 } 215 216 } 217 public String dumpBeanNode(){ 218 StringBuffer str = new StringBuffer (); 219 str.append(getClass().getName()); this.dump(str, "\n "); return str.toString(); 222 } 223 } 224 | Popular Tags |