KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > Configs


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 Configs matches the DTD element configs
26  *
27  */

28
29 package com.sun.enterprise.config.serverbeans;
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 Configs 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 CONFIG = "Config";
50
51     public Configs() {
52         this(Common.USE_DEFAULT_VALUES);
53     }
54
55     public Configs(int options)
56     {
57         super(comparators, runtimeVersion);
58         // Properties (see root bean comments for the bean graph)
59
initPropertyTables(1);
60         this.createProperty("config", CONFIG,
61             Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY,
62             Config.class);
63         this.createAttribute(CONFIG, "name", "Name",
64                         AttrProp.CDATA | AttrProp.REQUIRED,
65                         null, null);
66         this.createAttribute(CONFIG, "dynamic-reconfiguration-enabled", "DynamicReconfigurationEnabled",
67                         AttrProp.CDATA,
68                         null, "true");
69         this.initialize(options);
70     }
71
72     // Setting the default values of the properties
73
void initialize(int options) {
74
75     }
76
77     // This attribute is an array containing at least one element
78
public void setConfig(int index, Config value) {
79         this.setValue(CONFIG, index, value);
80     }
81
82     // Get Method
83
public Config getConfig(int index) {
84         return (Config)this.getValue(CONFIG, index);
85     }
86
87     // This attribute is an array containing at least one element
88
public void setConfig(Config[] value) {
89         this.setValue(CONFIG, value);
90     }
91
92     // Getter Method
93
public Config[] getConfig() {
94         return (Config[])this.getValues(CONFIG);
95     }
96
97     // Return the number of properties
98
public int sizeConfig() {
99         return this.size(CONFIG);
100     }
101
102     // Add a new element returning its index in the list
103
public int addConfig(Config value)
104             throws ConfigException{
105         return addConfig(value, true);
106     }
107
108     // Add a new element returning its index in the list with a boolean flag
109
public int addConfig(Config value, boolean overwrite)
110             throws ConfigException{
111         Config old = getConfigByName(value.getName());
112         if(old != null) {
113             throw new ConfigException(StringManager.getManager(Configs.class).getString("cannotAddDuplicate", "Config"));
114         }
115         return this.addValue(CONFIG, value, overwrite);
116     }
117
118     //
119
// Remove an element using its reference
120
// Returns the index the element had in the list
121
//
122
public int removeConfig(Config value){
123         return this.removeValue(CONFIG, value);
124     }
125
126     //
127
// Remove an element using its reference
128
// Returns the index the element had in the list
129
// with boolean overwrite
130
//
131
public int removeConfig(Config value, boolean overwrite)
132             throws StaleWriteConfigException{
133         return this.removeValue(CONFIG, value, overwrite);
134     }
135
136     public Config getConfigByName(String JavaDoc id) {
137      if (null != id) { id = id.trim(); }
138     Config[] o = getConfig();
139      if (o == null) return null;
140
141      for (int i=0; i < o.length; i++) {
142          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
143              return o[i];
144          }
145      }
146
147         return null;
148         
149     }
150     /**
151      * Create a new bean using it's default constructor.
152      * This does not add it to any bean graph.
153      */

154     public Config newConfig() {
155         return new Config();
156     }
157
158     /**
159     * get the xpath representation for this element
160     * returns something like abc[@name='value'] or abc
161     * depending on the type of the bean
162     */

163     protected String JavaDoc getRelativeXPath() {
164         String JavaDoc ret = null;
165         ret = "configs";
166         return (null != ret ? ret.trim() : null);
167     }
168
169     /*
170     * generic method to get default value from dtd
171     */

172     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
173         if(attr == null) return null;
174         attr = attr.trim();
175     return null;
176     }
177     //
178
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
179         comparators.add(c);
180     }
181
182     //
183
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
184         comparators.remove(c);
185     }
186     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
187     }
188
189     // Dump the content of this bean returning it as a String
190
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
191         String JavaDoc s;
192         Object JavaDoc o;
193         org.netbeans.modules.schema2beans.BaseBean n;
194         str.append(indent);
195         str.append("Config["+this.sizeConfig()+"]"); // NOI18N
196
for(int i=0; i<this.sizeConfig(); i++)
197         {
198             str.append(indent+"\t");
199             str.append("#"+i+":");
200             n = (org.netbeans.modules.schema2beans.BaseBean) this.getConfig(i);
201             if (n != null)
202                 n.dump(str, indent + "\t"); // NOI18N
203
else
204                 str.append(indent+"\tnull"); // NOI18N
205
this.dumpAttributes(CONFIG, i, str, indent);
206         }
207
208     }
209     public String JavaDoc dumpBeanNode(){
210         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
211         str.append("Configs\n"); // NOI18N
212
this.dump(str, "\n "); // NOI18N
213
return str.toString();
214     }}
215
216 // END_NOI18N
217

218
Popular Tags