KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > clientbeans > ProviderConfig


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /**
25  * This generated bean class ProviderConfig matches the DTD element provider-config
26  *
27  */

28
29 package com.sun.enterprise.config.clientbeans;
30
31 import org.w3c.dom.*;
32 import org.netbeans.modules.schema2beans.*;
33 import java.beans.*;
34 import java.util.*;
35 import java.io.Serializable JavaDoc;
36 import com.sun.enterprise.config.ConfigBean;
37 import com.sun.enterprise.config.ConfigException;
38 import com.sun.enterprise.config.StaleWriteConfigException;
39 import com.sun.enterprise.util.i18n.StringManager;
40
41 // BEGIN_NOI18N
42

43 public class ProviderConfig extends ConfigBean implements Serializable JavaDoc
44 {
45
46     static Vector comparators = new Vector();
47     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
48
49     static public final String JavaDoc REQUEST_POLICY = "RequestPolicy";
50     static public final String JavaDoc RESPONSE_POLICY = "ResponsePolicy";
51     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
52
53     public ProviderConfig() {
54         this(Common.USE_DEFAULT_VALUES);
55     }
56
57     public ProviderConfig(int options)
58     {
59         super(comparators, runtimeVersion);
60         // Properties (see root bean comments for the bean graph)
61
initPropertyTables(3);
62         this.createProperty("request-policy", REQUEST_POLICY,
63             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
64             RequestPolicy.class);
65         this.createAttribute(REQUEST_POLICY, "auth-source", "AuthSource",
66                         AttrProp.ENUM | AttrProp.IMPLIED,
67                         new String JavaDoc[] {
68                             "sender",
69                             "content"
70                         }, null);
71         this.createAttribute(REQUEST_POLICY, "auth-recipient", "AuthRecipient",
72                         AttrProp.ENUM | AttrProp.IMPLIED,
73                         new String JavaDoc[] {
74                             "before-content",
75                             "after-content"
76                         }, null);
77         this.createProperty("response-policy", RESPONSE_POLICY,
78             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
79             ResponsePolicy.class);
80         this.createAttribute(RESPONSE_POLICY, "auth-source", "AuthSource",
81                         AttrProp.ENUM | AttrProp.IMPLIED,
82                         new String JavaDoc[] {
83                             "sender",
84                             "content"
85                         }, null);
86         this.createAttribute(RESPONSE_POLICY, "auth-recipient", "AuthRecipient",
87                         AttrProp.ENUM | AttrProp.IMPLIED,
88                         new String JavaDoc[] {
89                             "before-content",
90                             "after-content"
91                         }, null);
92         this.createProperty("property", ELEMENT_PROPERTY,
93             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
94             ElementProperty.class);
95         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
96                         AttrProp.CDATA | AttrProp.REQUIRED,
97                         null, null);
98         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
99                         AttrProp.CDATA | AttrProp.REQUIRED,
100                         null, null);
101         this.initialize(options);
102     }
103
104     // Setting the default values of the properties
105
void initialize(int options) {
106
107     }
108
109     // This attribute is optional
110
public void setRequestPolicy(RequestPolicy value) {
111         this.setValue(REQUEST_POLICY, value);
112     }
113
114     // Get Method
115
public RequestPolicy getRequestPolicy() {
116         return (RequestPolicy)this.getValue(REQUEST_POLICY);
117     }
118
119     // This attribute is optional
120
public void setResponsePolicy(ResponsePolicy value) {
121         this.setValue(RESPONSE_POLICY, value);
122     }
123
124     // Get Method
125
public ResponsePolicy getResponsePolicy() {
126         return (ResponsePolicy)this.getValue(RESPONSE_POLICY);
127     }
128
129     // This attribute is an array, possibly empty
130
public void setElementProperty(int index, ElementProperty value) {
131         this.setValue(ELEMENT_PROPERTY, index, value);
132     }
133
134     // Get Method
135
public ElementProperty getElementProperty(int index) {
136         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
137     }
138
139     // This attribute is an array, possibly empty
140
public void setElementProperty(ElementProperty[] value) {
141         this.setValue(ELEMENT_PROPERTY, value);
142     }
143
144     // Getter Method
145
public ElementProperty[] getElementProperty() {
146         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
147     }
148
149     // Return the number of properties
150
public int sizeElementProperty() {
151         return this.size(ELEMENT_PROPERTY);
152     }
153
154     // Add a new element returning its index in the list
155
public int addElementProperty(ElementProperty value)
156             throws ConfigException{
157         return addElementProperty(value, true);
158     }
159
160     // Add a new element returning its index in the list with a boolean flag
161
public int addElementProperty(ElementProperty value, boolean overwrite)
162             throws ConfigException{
163         ElementProperty old = getElementPropertyByName(value.getName());
164         if(old != null) {
165             throw new ConfigException(StringManager.getManager(ProviderConfig.class).getString("cannotAddDuplicate", "ElementProperty"));
166         }
167         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
168     }
169
170     //
171
// Remove an element using its reference
172
// Returns the index the element had in the list
173
//
174
public int removeElementProperty(ElementProperty value){
175         return this.removeValue(ELEMENT_PROPERTY, value);
176     }
177
178     //
179
// Remove an element using its reference
180
// Returns the index the element had in the list
181
// with boolean overwrite
182
//
183
public int removeElementProperty(ElementProperty value, boolean overwrite)
184             throws StaleWriteConfigException{
185         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
186     }
187
188     public ElementProperty getElementPropertyByName(String JavaDoc id) {
189      if (null != id) { id = id.trim(); }
190     ElementProperty[] o = getElementProperty();
191      if (o == null) return null;
192
193      for (int i=0; i < o.length; i++) {
194          if(o[i].getAttributeValue(Common.convertName(ClientTags.NAME)).equals(id)) {
195              return o[i];
196          }
197      }
198
199         return null;
200         
201     }
202     /**
203     * Getter for ProviderId of the Element provider-config
204     * @return the ProviderId of the Element provider-config
205     */

206     public String JavaDoc getProviderId() {
207         return getAttributeValue(ClientTags.PROVIDER_ID);
208     }
209     /**
210     * Modify the ProviderId of the Element provider-config
211     * @param v the new value
212     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
213     */

214     public void setProviderId(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
215         setAttributeValue(ClientTags.PROVIDER_ID, v, overwrite);
216     }
217     /**
218     * Modify the ProviderId of the Element provider-config
219     * @param v the new value
220     */

221     public void setProviderId(String JavaDoc v) {
222         setAttributeValue(ClientTags.PROVIDER_ID, v);
223     }
224     /**
225     * Getter for ProviderType of the Element provider-config
226     * @return the ProviderType of the Element provider-config
227     */

228     public String JavaDoc getProviderType() {
229         return getAttributeValue(ClientTags.PROVIDER_TYPE);
230     }
231     /**
232     * Modify the ProviderType of the Element provider-config
233     * @param v the new value
234     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
235     */

236     public void setProviderType(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
237         setAttributeValue(ClientTags.PROVIDER_TYPE, v, overwrite);
238     }
239     /**
240     * Modify the ProviderType of the Element provider-config
241     * @param v the new value
242     */

243     public void setProviderType(String JavaDoc v) {
244         setAttributeValue(ClientTags.PROVIDER_TYPE, v);
245     }
246     /**
247     * Getter for ClassName of the Element provider-config
248     * @return the ClassName of the Element provider-config
249     */

250     public String JavaDoc getClassName() {
251         return getAttributeValue(ClientTags.CLASS_NAME);
252     }
253     /**
254     * Modify the ClassName of the Element provider-config
255     * @param v the new value
256     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
257     */

258     public void setClassName(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
259         setAttributeValue(ClientTags.CLASS_NAME, v, overwrite);
260     }
261     /**
262     * Modify the ClassName of the Element provider-config
263     * @param v the new value
264     */

265     public void setClassName(String JavaDoc v) {
266         setAttributeValue(ClientTags.CLASS_NAME, v);
267     }
268     /**
269      * Create a new bean using it's default constructor.
270      * This does not add it to any bean graph.
271      */

272     public RequestPolicy newRequestPolicy() {
273         return new RequestPolicy();
274     }
275
276     /**
277      * Create a new bean using it's default constructor.
278      * This does not add it to any bean graph.
279      */

280     public ResponsePolicy newResponsePolicy() {
281         return new ResponsePolicy();
282     }
283
284     /**
285      * Create a new bean using it's default constructor.
286      * This does not add it to any bean graph.
287      */

288     public ElementProperty newElementProperty() {
289         return new ElementProperty();
290     }
291
292     /**
293     * get the xpath representation for this element
294     * returns something like abc[@name='value'] or abc
295     * depending on the type of the bean
296     */

297     protected String JavaDoc getRelativeXPath() {
298         String JavaDoc ret = null;
299         ret = "provider-config" + (canHaveSiblings() ? "[@provider-id='" + getAttributeValue("provider-id") +"']" : "") ;
300         return (null != ret ? ret.trim() : null);
301     }
302
303     /*
304     * generic method to get default value from dtd
305     */

306     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
307         if(attr == null) return null;
308         attr = attr.trim();
309     return null;
310     }
311     //
312
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
313         comparators.add(c);
314     }
315
316     //
317
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
318         comparators.remove(c);
319     }
320     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
321     }
322
323     // Dump the content of this bean returning it as a String
324
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
325         String JavaDoc s;
326         Object JavaDoc o;
327         org.netbeans.modules.schema2beans.BaseBean n;
328         str.append(indent);
329         str.append("RequestPolicy"); // NOI18N
330
n = (org.netbeans.modules.schema2beans.BaseBean) this.getRequestPolicy();
331         if (n != null)
332             n.dump(str, indent + "\t"); // NOI18N
333
else
334             str.append(indent+"\tnull"); // NOI18N
335
this.dumpAttributes(REQUEST_POLICY, 0, str, indent);
336
337         str.append(indent);
338         str.append("ResponsePolicy"); // NOI18N
339
n = (org.netbeans.modules.schema2beans.BaseBean) this.getResponsePolicy();
340         if (n != null)
341             n.dump(str, indent + "\t"); // NOI18N
342
else
343             str.append(indent+"\tnull"); // NOI18N
344
this.dumpAttributes(RESPONSE_POLICY, 0, str, indent);
345
346         str.append(indent);
347         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
348
for(int i=0; i<this.sizeElementProperty(); i++)
349         {
350             str.append(indent+"\t");
351             str.append("#"+i+":");
352             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
353             if (n != null)
354                 n.dump(str, indent + "\t"); // NOI18N
355
else
356                 str.append(indent+"\tnull"); // NOI18N
357
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
358         }
359
360     }
361     public String JavaDoc dumpBeanNode(){
362         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
363         str.append("ProviderConfig\n"); // NOI18N
364
this.dump(str, "\n "); // NOI18N
365
return str.toString();
366     }}
367
368 // END_NOI18N
369

370
Popular Tags