KickJava   Java API By Example, From Geeks To Geeks.

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


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 AlertService matches the DTD element alert-service
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 AlertService 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 ALERT_SUBSCRIPTION = "AlertSubscription";
50     static public final String JavaDoc ELEMENT_PROPERTY = "ElementProperty";
51
52     public AlertService() {
53         this(Common.USE_DEFAULT_VALUES);
54     }
55
56     public AlertService(int options)
57     {
58         super(comparators, runtimeVersion);
59         // Properties (see root bean comments for the bean graph)
60
initPropertyTables(2);
61         this.createProperty("alert-subscription", ALERT_SUBSCRIPTION,
62             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
63             AlertSubscription.class);
64         this.createAttribute(ALERT_SUBSCRIPTION, "name", "Name",
65                         AttrProp.CDATA | AttrProp.REQUIRED,
66                         null, null);
67         this.createProperty("property", ELEMENT_PROPERTY,
68             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
69             ElementProperty.class);
70         this.createAttribute(ELEMENT_PROPERTY, "name", "Name",
71                         AttrProp.CDATA | AttrProp.REQUIRED,
72                         null, null);
73         this.createAttribute(ELEMENT_PROPERTY, "value", "Value",
74                         AttrProp.CDATA | AttrProp.REQUIRED,
75                         null, null);
76         this.initialize(options);
77     }
78
79     // Setting the default values of the properties
80
void initialize(int options) {
81
82     }
83
84     // This attribute is an array, possibly empty
85
public void setAlertSubscription(int index, AlertSubscription value) {
86         this.setValue(ALERT_SUBSCRIPTION, index, value);
87     }
88
89     // Get Method
90
public AlertSubscription getAlertSubscription(int index) {
91         return (AlertSubscription)this.getValue(ALERT_SUBSCRIPTION, index);
92     }
93
94     // This attribute is an array, possibly empty
95
public void setAlertSubscription(AlertSubscription[] value) {
96         this.setValue(ALERT_SUBSCRIPTION, value);
97     }
98
99     // Getter Method
100
public AlertSubscription[] getAlertSubscription() {
101         return (AlertSubscription[])this.getValues(ALERT_SUBSCRIPTION);
102     }
103
104     // Return the number of properties
105
public int sizeAlertSubscription() {
106         return this.size(ALERT_SUBSCRIPTION);
107     }
108
109     // Add a new element returning its index in the list
110
public int addAlertSubscription(AlertSubscription value)
111             throws ConfigException{
112         return addAlertSubscription(value, true);
113     }
114
115     // Add a new element returning its index in the list with a boolean flag
116
public int addAlertSubscription(AlertSubscription value, boolean overwrite)
117             throws ConfigException{
118         AlertSubscription old = getAlertSubscriptionByName(value.getName());
119         if(old != null) {
120             throw new ConfigException(StringManager.getManager(AlertService.class).getString("cannotAddDuplicate", "AlertSubscription"));
121         }
122         return this.addValue(ALERT_SUBSCRIPTION, value, overwrite);
123     }
124
125     //
126
// Remove an element using its reference
127
// Returns the index the element had in the list
128
//
129
public int removeAlertSubscription(AlertSubscription value){
130         return this.removeValue(ALERT_SUBSCRIPTION, value);
131     }
132
133     //
134
// Remove an element using its reference
135
// Returns the index the element had in the list
136
// with boolean overwrite
137
//
138
public int removeAlertSubscription(AlertSubscription value, boolean overwrite)
139             throws StaleWriteConfigException{
140         return this.removeValue(ALERT_SUBSCRIPTION, value, overwrite);
141     }
142
143     public AlertSubscription getAlertSubscriptionByName(String JavaDoc id) {
144      if (null != id) { id = id.trim(); }
145     AlertSubscription[] o = getAlertSubscription();
146      if (o == null) return null;
147
148      for (int i=0; i < o.length; i++) {
149          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
150              return o[i];
151          }
152      }
153
154         return null;
155         
156     }
157     // This attribute is an array, possibly empty
158
public void setElementProperty(int index, ElementProperty value) {
159         this.setValue(ELEMENT_PROPERTY, index, value);
160     }
161
162     // Get Method
163
public ElementProperty getElementProperty(int index) {
164         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
165     }
166
167     // This attribute is an array, possibly empty
168
public void setElementProperty(ElementProperty[] value) {
169         this.setValue(ELEMENT_PROPERTY, value);
170     }
171
172     // Getter Method
173
public ElementProperty[] getElementProperty() {
174         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
175     }
176
177     // Return the number of properties
178
public int sizeElementProperty() {
179         return this.size(ELEMENT_PROPERTY);
180     }
181
182     // Add a new element returning its index in the list
183
public int addElementProperty(ElementProperty value)
184             throws ConfigException{
185         return addElementProperty(value, true);
186     }
187
188     // Add a new element returning its index in the list with a boolean flag
189
public int addElementProperty(ElementProperty value, boolean overwrite)
190             throws ConfigException{
191         ElementProperty old = getElementPropertyByName(value.getName());
192         if(old != null) {
193             throw new ConfigException(StringManager.getManager(AlertService.class).getString("cannotAddDuplicate", "ElementProperty"));
194         }
195         return this.addValue(ELEMENT_PROPERTY, value, overwrite);
196     }
197
198     //
199
// Remove an element using its reference
200
// Returns the index the element had in the list
201
//
202
public int removeElementProperty(ElementProperty value){
203         return this.removeValue(ELEMENT_PROPERTY, value);
204     }
205
206     //
207
// Remove an element using its reference
208
// Returns the index the element had in the list
209
// with boolean overwrite
210
//
211
public int removeElementProperty(ElementProperty value, boolean overwrite)
212             throws StaleWriteConfigException{
213         return this.removeValue(ELEMENT_PROPERTY, value, overwrite);
214     }
215
216     public ElementProperty getElementPropertyByName(String JavaDoc id) {
217      if (null != id) { id = id.trim(); }
218     ElementProperty[] o = getElementProperty();
219      if (o == null) return null;
220
221      for (int i=0; i < o.length; i++) {
222          if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) {
223              return o[i];
224          }
225      }
226
227         return null;
228         
229     }
230     /**
231      * Create a new bean using it's default constructor.
232      * This does not add it to any bean graph.
233      */

234     public AlertSubscription newAlertSubscription() {
235         return new AlertSubscription();
236     }
237
238     /**
239      * Create a new bean using it's default constructor.
240      * This does not add it to any bean graph.
241      */

242     public ElementProperty newElementProperty() {
243         return new ElementProperty();
244     }
245
246     /**
247     * get the xpath representation for this element
248     * returns something like abc[@name='value'] or abc
249     * depending on the type of the bean
250     */

251     protected String JavaDoc getRelativeXPath() {
252         String JavaDoc ret = null;
253         ret = "alert-service";
254         return (null != ret ? ret.trim() : null);
255     }
256
257     /*
258     * generic method to get default value from dtd
259     */

260     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
261         if(attr == null) return null;
262         attr = attr.trim();
263     return null;
264     }
265     //
266
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
267         comparators.add(c);
268     }
269
270     //
271
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
272         comparators.remove(c);
273     }
274     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
275     }
276
277     // Dump the content of this bean returning it as a String
278
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
279         String JavaDoc s;
280         Object JavaDoc o;
281         org.netbeans.modules.schema2beans.BaseBean n;
282         str.append(indent);
283         str.append("AlertSubscription["+this.sizeAlertSubscription()+"]"); // NOI18N
284
for(int i=0; i<this.sizeAlertSubscription(); i++)
285         {
286             str.append(indent+"\t");
287             str.append("#"+i+":");
288             n = (org.netbeans.modules.schema2beans.BaseBean) this.getAlertSubscription(i);
289             if (n != null)
290                 n.dump(str, indent + "\t"); // NOI18N
291
else
292                 str.append(indent+"\tnull"); // NOI18N
293
this.dumpAttributes(ALERT_SUBSCRIPTION, i, str, indent);
294         }
295
296         str.append(indent);
297         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
298
for(int i=0; i<this.sizeElementProperty(); i++)
299         {
300             str.append(indent+"\t");
301             str.append("#"+i+":");
302             n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i);
303             if (n != null)
304                 n.dump(str, indent + "\t"); // NOI18N
305
else
306                 str.append(indent+"\tnull"); // NOI18N
307
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
308         }
309
310     }
311     public String JavaDoc dumpBeanNode(){
312         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
313         str.append("AlertService\n"); // NOI18N
314
this.dump(str, "\n "); // NOI18N
315
return str.toString();
316     }}
317
318 // END_NOI18N
319

320
Popular Tags