KickJava   Java API By Example, From Geeks To Geeks.

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


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 WSAppExt extends DDXmi{
32     private static final String JavaDoc ROOT=TYPE_APP_EXT_APP_ID;
33
34     private static final String JavaDoc ROOT_NAME="ApplicationExt";
35
36     /** Creates a new instance of WSAppExt */
37     public WSAppExt() {
38         this(null, Common.USE_DEFAULT_VALUES);
39     }
40     public WSAppExt(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 WSAppExt(int options) {
49         super(options,ROOT);
50         //initOptions(options);
51
}
52     
53     public WSAppExt(File f,boolean validate) throws IOException{
54         this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES);
55     }
56     
57     public WSAppExt(InputStream in, boolean validate) {
58         this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES);
59     }
60     
61     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException {
62         if (doc == null) {
63             doc = GraphManager.createRootElementNode(ROOT); // NOI18N
64
if (doc == null)
65                 throw new Schema2BeansException(Common.getMessage(
66                         "CantCreateDOMRoot_msg", ROOT));
67         }
68         Node n = GraphManager.getElementNode(ROOT, doc); // NOI18N
69
if (n == null) {
70             throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName()));
71         }
72         this.graphManager.setXmlDocument(doc);
73         this.createBean(n, this.graphManager());
74         this.initialize(options);
75     };
76     
77     public void initialize(int options) {
78         
79     }
80     
81     public void setDefaults() {
82         setXmiVersion();
83         setNsXmi();
84         setNsXsi();
85         setNsAppExt();
86         setNsApp();
87         setXmiId("Application_ID_Ext");
88         setApplicationHref("Application_ID");
89     }
90     
91     protected void initOptions(int options) {
92         this.graphManager = new GraphManager(this);
93         this.createRoot(ROOT, ROOT_NAME, // NOI18N
94
Common.TYPE_1 | Common.TYPE_BEAN, WSAppExt.class);
95         
96         initPropertyTables(2);
97         this.createAttribute(XMI_ID_ID, XMI_ID, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
98         this.createAttribute(NS_APP_ID, NS_APP, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
99         this.createAttribute(NS_APP_EXT_ID, NS_APP_EXT, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
100         this.createAttribute(NS_XMI_ID, NS_XMI, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
101         this.createAttribute(NS_XSI_ID, NS_XSI, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
102         this.createAttribute(XMI_VERSION_ID,XMI_VERSION, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
103         this.createAttribute(RELOAD_ENABLED_ID,RELOAD_ENABLED, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
104         this.createAttribute(RELOAD_INTERVAL_ID,RELOAD_INTERVAL, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
105         this.createAttribute(SHARED_SESSION_CONTEXT_ID,SHARED_SESSION_CONTEXT, AttrProp.CDATA | AttrProp.IMPLIED,null, null);
106         
107         this.createProperty(MODULE_EXTENSIONS_ID,
108                 MODULE_EXTENSIONS,
109                 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
110                 ModuleExtensionsType.class);
111         this.createAttribute(MODULE_EXTENSIONS,XMI_TYPE_ID, MODULE_EXTENSIONS_XMI_TYPE,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
112         this.createAttribute(MODULE_EXTENSIONS,ALT_ROOT_ID , MODULE_EXTENSIONS_ALT_ROOT ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
113         this.createAttribute(MODULE_EXTENSIONS,ALT_BINDINGS_ID, MODULE_EXTENSIONS_ALT_BINDINGS ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
114         this.createAttribute(MODULE_EXTENSIONS,ALT_EXTENSIONS_ID , MODULE_EXTENSIONS_ALT_EXTENSIONS ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
115         this.createAttribute(MODULE_EXTENSIONS,XMI_ID_ID , MODULE_EXTENSIONS_XMI_ID ,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
116         
117         this.createProperty(APPLICATION_ID,
118                 APPLICATION,
119                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
120                 java.lang.String JavaDoc.class);
121         this.createAttribute(APPLICATION,HREF_ID,APPLICATION_HREF,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
122         this.initialize(options);
123     }
124     
125     public void setModuleExtensions(int index,ModuleExtensionsType value) {
126         this.setValue(MODULE_EXTENSIONS, index,value);
127     }
128     
129     public void setModuleExtensions(ModuleExtensionsType[]value) {
130         this.setValue(MODULE_EXTENSIONS, value);
131     }
132     //
133
public ModuleExtensionsType[] getModuleExtensions() {
134         return (ModuleExtensionsType[])this.getValues(MODULE_EXTENSIONS);
135     }
136     public ModuleExtensionsType getModuleExtensions(int index) {
137         return (ModuleExtensionsType)this.getValue(MODULE_EXTENSIONS,index);
138     }
139     public int sizeModuleExtensions() {
140         return this.size(MODULE_EXTENSIONS);
141     }
142     public int addModuleExtensions(ModuleExtensionsType value) {
143         int positionOfNewItem = this.addValue(MODULE_EXTENSIONS, value);
144         return positionOfNewItem;
145     }
146     
147     
148     public int removeModuleExtensions(ModuleExtensionsType value) {
149         return this.removeValue(MODULE_EXTENSIONS, value);
150     }
151     
152     public void setSharedSession(boolean value) {
153         this.setAttributeValue(SHARED_SESSION_CONTEXT, (value==true)?"true":"false");
154     }
155     //
156
public boolean getSharedSession() {
157         String JavaDoc getSharedSting=this.getAttributeValue(SHARED_SESSION_CONTEXT);
158         if(getSharedSting==null) return false;
159         else return (getSharedSting.equals("true")?true:false);
160     }
161     
162     
163     
164     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
165         if (getModuleExtensions()!= null) {
166             // Validating property jdbcConnectionPool
167
for (int _index = 0; _index < sizeModuleExtensions(); ++_index) {
168                 ModuleExtensionsType element = getModuleExtensions(_index);
169                 if (element != null) {
170                     element.validate();
171                 }
172             }
173         }
174         if (getApplication()== null) {
175             throw new org.netbeans.modules.schema2beans.ValidateException("getApplication() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, APPLICATION, this); // NOI18N
176
}
177         if(getApplicationHref()==null) {
178             throw new org.netbeans.modules.schema2beans.ValidateException("getApplicationHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, APPLICATION, this); // NOI18N
179
}
180         if(getNsApp()==null) {
181             throw new org.netbeans.modules.schema2beans.ValidateException("getNsApp() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
182
}
183         if(getNsAppExt()==null) {
184             throw new org.netbeans.modules.schema2beans.ValidateException("getNsAppExt() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
185
}
186         if(getNsCommon()==null) {
187             throw new org.netbeans.modules.schema2beans.ValidateException("getNsCommon() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
188
}
189         if(getNsXmi()==null) {
190             throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
191
}
192         if(getXmiId()==null) {
193             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
194
}
195         if(getXmiVersion()==null) {
196             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
197
}
198         
199     }
200     
201     public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
202         String JavaDoc s;
203         Object JavaDoc o;
204         BaseBean n;
205         
206         str.append(indent);
207         str.append(MODULE_EXTENSIONS+"["+this.sizeModuleExtensions()+"]"); // NOI18N
208
for(int i=0; i<this.sizeModuleExtensions(); i++) {
209             str.append(indent+"\t");
210             str.append("#"+i+":");
211             n = (BaseBean) this.getModuleExtensions(i);
212             if (n != null)
213                 n.dump(str, indent + "\t"); // NOI18N
214
else
215                 str.append(indent+"\tnull"); // NOI18N
216
this.dumpAttributes(MODULE_EXTENSIONS, i, str, indent);
217         }
218         str.append(indent);
219         str.append(APPLICATION); // NOI18N
220
str.append(indent+"\t"); // NOI18N
221
str.append("<"); // NOI18N
222
o = this.getApplication();
223         str.append((o==null?"null":o.toString().trim())); // NOI18N
224
str.append(">\n"); // NOI18N
225
this.dumpAttributes(APPLICATION, 0, str, indent);
226     }
227     public String JavaDoc dumpBeanNode(){
228         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
229         str.append(getClass().getName()); // NOI18N
230
this.dump(str, "\n "); // NOI18N
231
return str.toString();
232     }
233 }
234
Popular Tags