KickJava   Java API By Example, From Geeks To Geeks.

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


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 WSEjbExt extends DDXmi{
32     private static final String JavaDoc ROOT=TYPE_EJB_EXT_ID;
33
34     private static final String JavaDoc ROOT_NAME="EjbJarExt";
35
36     /** Creates a new instance of WSAppExt */
37     public WSEjbExt() {
38         this(null, Common.USE_DEFAULT_VALUES);
39     }
40     public WSEjbExt(org.w3c.dom.Node JavaDoc doc, int options) {
41         this(Common.NO_DEFAULT_VALUES);
42         try {
43             initFromNode(doc, options);
44         } catch (Schema2BeansException e) {
45             throw new RuntimeException JavaDoc(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 JavaDoc doc, int options) throws Schema2BeansException {
57         if (doc == null) {
58             doc = GraphManager.createRootElementNode(ROOT); // NOI18N
59
if (doc == null)
60                 throw new Schema2BeansException(Common.getMessage(
61                         "CantCreateDOMRoot_msg", ROOT));
62         }
63         Node n = GraphManager.getElementNode(ROOT, doc); // NOI18N
64
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, // NOI18N
92
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, // NOI18N
112
EJB_JAR,
113                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
114                 java.lang.String JavaDoc.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     //
127
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     //
142
// Remove an element using its reference
143
// Returns the index the element had in the list
144
//
145
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             // Validating property jdbcConnectionPool
157
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); // NOI18N
167
}
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); // NOI18N
170
}
171         if (getNsEjb()==null) {
172             throw new org.netbeans.modules.schema2beans.ValidateException("getNsEjb() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
173
}
174         if (getNsEjbExt()==null) {
175             throw new org.netbeans.modules.schema2beans.ValidateException("getNsEjbExt() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
176
}
177         if (getNsXmi()==null) {
178             throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
179
}
180         if(getXmiId()==null) {
181             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
182
}
183         if(getXmiVersion()==null) {
184             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
185
}
186         
187     }
188     
189     public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
190         String JavaDoc s;
191         Object JavaDoc o;
192         BaseBean n;
193         
194         str.append(indent);
195         str.append(EJB_JAR); // NOI18N
196
str.append(indent+"\t"); // NOI18N
197
str.append("<"); // NOI18N
198
o = this.getApplication();
199         str.append((o==null?"null":o.toString().trim())); // NOI18N
200
str.append(">\n"); // NOI18N
201
this.dumpAttributes(EJB_JAR, 0, str, indent);
202         
203         str.append(indent);
204         str.append(EJB_EXTENSIONS+"["+this.sizeEjbExtensions()+"]"); // NOI18N
205
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"); // NOI18N
211
else
212                 str.append(indent+"\tnull"); // NOI18N
213
this.dumpAttributes(EJB_EXTENSIONS, i, str, indent);
214         }
215         
216     }
217     public String JavaDoc dumpBeanNode(){
218         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
219         str.append(getClass().getName()); // NOI18N
220
this.dump(str, "\n "); // NOI18N
221
return str.toString();
222     }
223 }
224
Popular Tags