KickJava   Java API By Example, From Geeks To Geeks.

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


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 WSAppBnd extends DDXmi{
32
33     private static final String JavaDoc ROOT=TYPE_APP_BND_ID;
34     private static final String JavaDoc ROOT_NAME="ApplicationBnd";
35
36
37     /** Creates a new instance of AppBndXmi */
38     public WSAppBnd() {
39         this(null, Common.USE_DEFAULT_VALUES);
40     }
41     public WSAppBnd(org.w3c.dom.Node JavaDoc doc, int options) {
42         this(Common.NO_DEFAULT_VALUES);
43         try {
44             initFromNode(doc, options);
45         } catch (Schema2BeansException e) {
46             throw new RuntimeException JavaDoc(e);
47         }
48     }
49     
50     public WSAppBnd(int options) {
51         super(options,ROOT);
52         //initOptions(options);
53
}
54     
55     
56     public WSAppBnd(File f,boolean validate) throws IOException{
57         this(GraphManager.createXmlDocument(new FileInputStream(f), validate), Common.NO_DEFAULT_VALUES);
58     }
59     
60     public WSAppBnd(InputStream in, boolean validate) {
61         this(GraphManager.createXmlDocument(in, validate), Common.NO_DEFAULT_VALUES);
62     }
63     
64     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException {
65         if (doc == null) {
66             doc = GraphManager.createRootElementNode(ROOT); // NOI18N
67
if (doc == null)
68                 throw new Schema2BeansException(Common.getMessage(
69                         "CantCreateDOMRoot_msg", ROOT));
70         }
71         Node n = GraphManager.getElementNode(ROOT, doc); // NOI18N
72
if (n == null) {
73             throw new Schema2BeansException(Common.getMessage("DocRootNotInDOMGraph_msg", ROOT, doc.getFirstChild().getNodeName()));
74         }
75         this.graphManager.setXmlDocument(doc);
76         this.createBean(n, this.graphManager());
77         this.initialize(options);
78     };
79     
80     public void initialize(int options) {
81     }
82     
83     
84     public void setDefaults() {
85         setNsApp();
86         setNsAppBnd();
87         setNsCommon();
88         setNsXmi();
89         setNsXsi();
90         setXmiId("Application_ID_Bnd");
91         setAuthTable(new AuthorizationTableType());
92         setAuthTableId(AUTH_TABLE+"_1");
93         setApplication("");
94         setApplicationHref("Application_ID");
95     }
96     protected void initOptions(int options) {
97         this.graphManager = new GraphManager(this);
98         this.createRoot(ROOT, ROOT_NAME,
99                 Common.TYPE_1 | Common.TYPE_BEAN, WSAppBnd.class);
100         
101         this.createAttribute(XMI_ID_ID, XMI_ID,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
102         this.createAttribute(NS_APP_ID, NS_APP,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
103         this.createAttribute(NS_COMMON_ID, NS_COMMON,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
104         this.createAttribute(NS_APP_BND_ID,NS_APP_BND,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
105         this.createAttribute(NS_XMI_ID, NS_XMI,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
106         this.createAttribute(NS_XSI_ID, NS_XSI,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
107         this.createAttribute(XMI_VERSION_ID,XMI_VERSION,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
108         // Properties (see root bean comments for the bean graph)
109
initPropertyTables(3);
110         
111         this.createProperty(AUTH_TABLE_ID,
112                 AUTH_TABLE,
113                 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
114                 AuthorizationTableType.class);
115         this.createAttribute(AUTH_TABLE,XMI_ID_ID,AUTH_TABLE_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         
123         
124         this.createProperty(RUN_AS_MAP_ID,
125                 RUN_AS_MAP,
126                 Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
127                 java.lang.String JavaDoc.class);
128         this.createAttribute(RUN_AS_MAP,XMI_ID_ID,RUN_AS_MAP_XMI_ID,AttrProp.CDATA | AttrProp.IMPLIED,null, null);
129         this.initialize(options);
130     }
131     
132     public void setAuthTable(AuthorizationTableType value) {
133         this.setValue(AUTH_TABLE, value);
134     }
135     
136     //
137
public AuthorizationTableType getAuthorizationTable() {
138         return (AuthorizationTableType)this.getValue(AUTH_TABLE);
139     }
140     public int sizeAuthorizationTable() {
141         return this.size(AUTH_TABLE);
142     }
143     
144     public void setAuthTableId(String JavaDoc value) {
145         setAttributeValue(AUTH_TABLE,AUTH_TABLE_XMI_ID,value);
146     }
147     public String JavaDoc getAuthTableId(){
148         return (String JavaDoc)getAttributeValue(AUTH_TABLE,AUTH_TABLE_XMI_ID);
149     }
150     
151     public void setRunAsMapId(String JavaDoc value) {
152         if(getRunAsMap()==null) {
153             setRunAsMap("");
154         }
155         setAttributeValue(RUN_AS_MAP,RUN_AS_MAP_XMI_ID,value);
156     }
157     public String JavaDoc getRunAsMapId(){
158         if(getRunAsMap()==null) {
159             return null;
160         }
161         return (String JavaDoc)getAttributeValue(RUN_AS_MAP,RUN_AS_MAP_XMI_ID);
162     }
163     public void setRunAsMap(String JavaDoc value) {
164         setValue(RUN_AS_MAP,value);
165     }
166     public String JavaDoc getRunAsMap(){
167         return (String JavaDoc)getValue(RUN_AS_MAP);
168     }
169     
170     
171     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
172         
173         if (getAuthorizationTable()!= null) {
174             getAuthorizationTable().validate();
175         } else {
176             throw new org.netbeans.modules.schema2beans.ValidateException("getAuthorizationTable() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, AUTH_TABLE, this); // NOI18N
177
}
178         
179         if (getApplication()== null) {
180             throw new org.netbeans.modules.schema2beans.ValidateException("getApplication() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, APPLICATION, this); // NOI18N
181
}
182         if(getApplicationHref()==null) {
183             throw new org.netbeans.modules.schema2beans.ValidateException("getApplicationHref() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, APPLICATION, this); // NOI18N
184
}
185         if(getNsApp()==null) {
186             throw new org.netbeans.modules.schema2beans.ValidateException("getNsApp() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
187
}
188         if(getNsAppBnd()==null) {
189             throw new org.netbeans.modules.schema2beans.ValidateException("getNsAppBnd() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
190
}
191         if(getNsCommon()==null) {
192             throw new org.netbeans.modules.schema2beans.ValidateException("getNsCommon() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
193
}
194         if(getNsXmi()==null) {
195             throw new org.netbeans.modules.schema2beans.ValidateException("getNsXmi() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
196
}
197         if(getAuthorizationTable()!=null)
198             if(getAuthTableId()==null) {
199             throw new org.netbeans.modules.schema2beans.ValidateException("getAuthTableId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, AUTH_TABLE, this); // NOI18N
200
}
201         if(getXmiId()==null) {
202             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiId() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
203
}
204         if(getXmiVersion()==null) {
205             throw new org.netbeans.modules.schema2beans.ValidateException("getXmiVersion() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, ROOT, this); // NOI18N
206
}
207     }
208     
209     public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
210         String JavaDoc s;
211         Object JavaDoc o;
212         org.netbeans.modules.schema2beans.BaseBean n;
213         
214         str.append(indent);
215         str.append(AUTH_TABLE); // NOI18N
216
n = (org.netbeans.modules.schema2beans.BaseBean) this.getAuthorizationTable();
217         if (n != null)
218             n.dump(str, indent + "\t"); // NOI18N
219
else
220             str.append(indent+"\tnull"); // NOI18N
221
this.dumpAttributes(AUTH_TABLE, 0, str, indent);
222         
223         str.append(indent);
224         str.append(APPLICATION); // NOI18N
225
str.append(indent+"\t"); // NOI18N
226
str.append("<"); // NOI18N
227
o = this.getApplication();
228         str.append((o==null?"null":o.toString().trim())); // NOI18N
229
str.append(">\n"); // NOI18N
230
this.dumpAttributes(APPLICATION, 0, str, indent);
231     }
232     public String JavaDoc dumpBeanNode(){
233         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
234         str.append(getClass().getName()); // NOI18N
235
this.dump(str, "\n "); // NOI18N
236
return str.toString();
237     }
238 }
239
Popular Tags