KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > beans > WSWebBnd


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 /**
28  *
29  * @author dlm198383
30  */

31 public class WSWebBnd extends DDXmi {
32     private static final String JavaDoc ROOT=TYPE_WEB_APP_BND_ID;
33
34     private static final String JavaDoc ROOT_NAME="WebApplicationBnd";
35
36
37
38     /** Creates a new instance of WSAppBnd */
39     public WSWebBnd() {
40         this(null, Common.USE_DEFAULT_VALUES);
41     }
42     public WSWebBnd(org.w3c.dom.Node JavaDoc doc, int options) {
43         this(Common.NO_DEFAULT_VALUES);
44         try {
45             initFromNode(doc, options);
46         } catch (Schema2BeansException e) {
47             throw new RuntimeException JavaDoc(e);
48         }
49     }
50     public WSWebBnd(int options) {
51         super(options,ROOT);
52     }
53     
54     
55     public WSWebBnd(File f,boolean validate) throws IOException{
56         this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES);
57     }
58     
59     public WSWebBnd(InputStream in, boolean validate) {
60         this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES);
61     }
62     
63     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException {
64         if (doc == null) {
65             doc = GraphManager.createRootElementNode(ROOT); // NOI18N
66
if (doc == null)
67                 throw new Schema2BeansException(Common.getMessage(
68                         "CantCreateDOMRoot_msg", ROOT));
69         }
70         Node n = GraphManager.getElementNode(ROOT, doc); // NOI18N
71
if (n == null) {
72             throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName()));
73         }
74         this.graphManager.setXmlDocument(doc);
75         this.createBean(n, this.graphManager());
76         this.initialize(options);
77     };
78     public void initialize(int options) {
79         
80     }
81     
82     public void setDefaults() {
83         setNsWebAppBnd();
84         setNsWebApp();
85         setXmiVersion();
86         setNsXmi();
87         setNsCommon();
88         setNsCommonBnd();
89         setXmiId("WebAppBinding");
90         setVirtualHostName("default_host");
91         setWebApplication("");
92         setWebApplicationHref("WebApp");
93     }
94     
95     protected void initOptions(int options) {
96         this.graphManager = new GraphManager(this);
97         this.createRoot(ROOT, ROOT_NAME, // NOI18N
98
Common.TYPE_1 | Common.TYPE_BEAN, WSWebBnd.class);
99         initPropertyTables(3);
100         //this.createAttribute(ROOT_NAME,XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
101
this.createAttribute(XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
102         this.createAttribute(NS_COMMON_ID, NS_COMMON, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
103         this.createAttribute(NS_COMMON_BND_ID, NS_COMMON_BND, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
104         this.createAttribute(NS_XMI_ID, NS_XMI, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
105         this.createAttribute(XMI_VERSION_ID, XMI_VERSION, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
106         
107         this.createAttribute(NS_WEB_APP_ID, NS_WEB_APP, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
108         this.createAttribute(NS_WEB_APP_BND_ID, NS_WEB_APP_BND, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
109         this.createAttribute(VIRTUAL_HOST_NAME_ID, VIRTUAL_HOST_NAME,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
110         
111         this.createProperty(RES_REF_BINDINGS_ID,
112                 RES_REF_BINDINGS,
113                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
114                 ResRefBindingsType.class);
115         this.createAttribute(RES_REF_BINDINGS,XMI_ID_ID ,RES_REF_BINDINGS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
116         this.createAttribute(RES_REF_BINDINGS,JNDI_NAME_ID ,RES_REF_BINDINGS_JNDI_NAME ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
117         
118         this.createProperty(EJB_REF_BINDINGS_ID,
119                 EJB_REF_BINDINGS,
120                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
121                 EjbRefBindingsType.class);
122         this.createAttribute(EJB_REF_BINDINGS,XMI_ID_ID ,EJB_REF_BINDINGS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
123         this.createAttribute(EJB_REF_BINDINGS,JNDI_NAME_ID ,EJB_REF_BINDINGS_JNDI_NAME ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
124         
125         this.createProperty(RES_ENV_REF_BINDINGS_ID,
126                 RES_ENV_REF_BINDINGS,
127                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
128                 ResEnvRefBindingsType.class);
129         this.createAttribute(RES_ENV_REF_BINDINGS,XMI_ID_ID ,RES_ENV_REF_BINDINGS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
130         this.createAttribute(RES_ENV_REF_BINDINGS,JNDI_NAME_ID ,RES_ENV_REF_BINDINGS_JNDI_NAME ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
131         
132         this.createProperty(WEB_aPPLICATION_ID, // NOI18N
133
WEB_APPLICATION,
134                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
135                 java.lang.String JavaDoc.class);
136         this.createAttribute(WEB_APPLICATION,HREF_ID,WEB_APPLICATION_HREF,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
137         this.initialize(options);
138     }
139     
140     // functions for manupulation ResRefBindings
141
public void setResRefBindings(int index,ResRefBindingsType value) {
142         this.setValue(RES_REF_BINDINGS, index,value);
143     }
144     
145     public void setResRefBindings(ResRefBindingsType[]value) {
146         this.setValue(RES_REF_BINDINGS, value);
147     }
148     
149     public ResRefBindingsType[] getResRefBindings() {
150         return (ResRefBindingsType[]) this.getValues(RES_REF_BINDINGS);
151     }
152     public ResRefBindingsType getResRefBindings(int index) {
153         return (ResRefBindingsType)this.getValue(RES_REF_BINDINGS,index);
154     }
155     public int sizeResRefBindings() {
156         return this.size(RES_REF_BINDINGS);
157     }
158     public int addResRefBindings(ResRefBindingsType value) {
159         int positionOfNewItem = this.addValue(RES_REF_BINDINGS, value);
160         return positionOfNewItem;
161     }
162     
163     public int removeResRefBindings(ResRefBindingsType value) {
164         return this.removeValue(RES_REF_BINDINGS, value);
165     }
166         
167 // functions for manupulation ResEnvRefBindings
168
public void setResEnvRefBindings(int index,ResEnvRefBindingsType value) {
169         this.setValue(RES_ENV_REF_BINDINGS, index,value);
170     }
171     
172     public void setResEnvRefBindings(ResEnvRefBindingsType[]value) {
173         this.setValue(RES_ENV_REF_BINDINGS, value);
174     }
175     
176     public ResEnvRefBindingsType[] getResEnvRefBindings() {
177         return (ResEnvRefBindingsType[]) this.getValues(RES_ENV_REF_BINDINGS);
178     }
179     public ResEnvRefBindingsType getResEnvRefBindings(int index) {
180         return (ResEnvRefBindingsType)this.getValue(RES_ENV_REF_BINDINGS,index);
181     }
182     public int sizeResEnvRefBindings() {
183         return this.size(RES_ENV_REF_BINDINGS);
184     }
185     public int addResEnvRefBindings(ResEnvRefBindingsType value) {
186         int positionOfNewItem = this.addValue(RES_ENV_REF_BINDINGS, value);
187         return positionOfNewItem;
188     }
189     
190     public int removeResEnvRefBindings(ResEnvRefBindingsType value) {
191         return this.removeValue(RES_ENV_REF_BINDINGS, value);
192     }
193     
194         // functions for manupulation EjbRefBindings
195
public void setEjbRefBindings(int index,EjbRefBindingsType value) {
196         this.setValue(EJB_REF_BINDINGS, index,value);
197     }
198     
199     public void setEjbRefBindings(EjbRefBindingsType[]value) {
200         this.setValue(EJB_REF_BINDINGS, value);
201     }
202     
203     public EjbRefBindingsType[] getEjbRefBindings() {
204         return (EjbRefBindingsType[]) this.getValues(EJB_REF_BINDINGS);
205     }
206     public EjbRefBindingsType getEjbRefBindings(int index) {
207         return (EjbRefBindingsType)this.getValue(EJB_REF_BINDINGS,index);
208     }
209     public int sizeEjbRefBindings() {
210         return this.size(EJB_REF_BINDINGS);
211     }
212     public int addEjbRefBindings(EjbRefBindingsType value) {
213         int positionOfNewItem = this.addValue(EJB_REF_BINDINGS, value);
214         return positionOfNewItem;
215     }
216     
217     public int removeEjbRefBindings(EjbRefBindingsType value) {
218         return this.removeValue(EJB_REF_BINDINGS, value);
219     }
220     
221     
222     public void setVirtualHostName(String JavaDoc value) {
223         setAttributeValue(VIRTUAL_HOST_NAME,value);
224     }
225     
226     public String JavaDoc getVirtualHostName(){
227         return (String JavaDoc)getAttributeValue(VIRTUAL_HOST_NAME);
228     }
229     
230     
231     
232     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
233         if (getResRefBindings()!= null) {
234             for (int _index = 0; _index < sizeResRefBindings(); ++_index) {
235                 ResRefBindingsType element = getResRefBindings(_index);
236                 if (element != null) {
237                     element.validate();
238                 }
239             }
240         }
241         
242         if (getEjbRefBindings()!= null) {
243             for (int _index = 0; _index < sizeEjbRefBindings(); ++_index) {
244                 EjbRefBindingsType element = getEjbRefBindings(_index);
245                 if (element != null) {
246                     element.validate();
247                 }
248             }
249         }
250         if (getResEnvRefBindings()!= null) {
251             for (int _index = 0; _index < sizeResEnvRefBindings(); ++_index) {
252                 ResEnvRefBindingsType element = getResEnvRefBindings(_index);
253                 if (element != null) {
254                     element.validate();
255                 }
256             }
257         }
258         if (getNsCommon()==null) {
259             throw new org.netbeans.modules.schema2beans.ValidateException("getNsCommon() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
260
}
261         if (getNsCommonBnd()==null) {
262             throw new org.netbeans.modules.schema2beans.ValidateException("getNsCommonBnd() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
263
}
264         if (getNsXmi()==null) {
265             throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
266
}
267         if(getXmiVersion()==null) {
268             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
269
}
270         
271         if (getWebApplication()== null) {
272             throw new org.netbeans.modules.schema2beans.ValidateException("getWebApplication() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, WEB_APPLICATION, this); // NOI18N
273
}
274         if (getWebApplicationHref()==null) {
275             throw new org.netbeans.modules.schema2beans.ValidateException("getWebApplicationHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, WEB_APPLICATION, this); // NOI18N
276
}
277         if (getNsWebApp()==null) {
278             throw new org.netbeans.modules.schema2beans.ValidateException("getNsWebApp() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
279
}
280         if (getNsWebAppBnd()==null) {
281             throw new org.netbeans.modules.schema2beans.ValidateException("getNsWebAppBnd() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
282
}
283         
284         if(getXmiId()==null) {
285             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
286
}
287         if(getVirtualHostName()==null) {
288             throw new org.netbeans.modules.schema2beans.ValidateException("getVirtualHostName() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
289
}
290     }
291     
292     public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
293         String JavaDoc s;
294         Object JavaDoc o;
295         BaseBean n;
296         
297         str.append(indent);
298         str.append(WEB_APPLICATION); // NOI18N
299
str.append(indent+"\t"); // NOI18N
300
str.append("<"); // NOI18N
301
o = this.getApplication();
302         str.append((o==null?"null":o.toString().trim())); // NOI18N
303
str.append(">\n"); // NOI18N
304
this.dumpAttributes(WEB_APPLICATION, 0, str, indent);
305         
306         str.append(indent);
307         str.append(RES_REF_BINDINGS+"["+this.sizeResRefBindings()+"]"); // NOI18N
308
for(int i=0; i<this.sizeResRefBindings(); i++) {
309             str.append(indent+"\t");
310             str.append("#"+i+":");
311             n = (BaseBean) this.getResRefBindings(i);
312             if (n != null)
313                 n.dump(str, indent + "\t"); // NOI18N
314
else
315                 str.append(indent+"\tnull"); // NOI18N
316
this.dumpAttributes(RES_REF_BINDINGS, i, str, indent);
317         }
318         
319         
320         str.append(indent);
321         str.append(EJB_REF_BINDINGS+"["+this.sizeEjbRefBindings()+"]"); // NOI18N
322
for(int i=0; i<this.sizeEjbRefBindings(); i++) {
323             str.append(indent+"\t");
324             str.append("#"+i+":");
325             n = (BaseBean) this.getEjbRefBindings(i);
326             if (n != null)
327                 n.dump(str, indent + "\t"); // NOI18N
328
else
329                 str.append(indent+"\tnull"); // NOI18N
330
this.dumpAttributes(EJB_REF_BINDINGS, i, str, indent);
331         }
332         
333         
334         str.append(RES_ENV_REF_BINDINGS+"["+this.sizeResEnvRefBindings()+"]"); // NOI18N
335
for(int i=0; i<this.sizeResEnvRefBindings(); i++) {
336             str.append(indent+"\t");
337             str.append("#"+i+":");
338             n = (BaseBean) this.getResEnvRefBindings(i);
339             if (n != null)
340                 n.dump(str, indent + "\t"); // NOI18N
341
else
342                 str.append(indent+"\tnull"); // NOI18N
343
this.dumpAttributes(RES_ENV_REF_BINDINGS, i, str, indent);
344         }
345     }
346     public String JavaDoc dumpBeanNode(){
347         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
348         str.append(getClass().getName()); // NOI18N
349
this.dump(str, "\n "); // NOI18N
350
return str.toString();
351     }
352 }
353
Popular Tags