KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > sunresources > beans > FieldGroup


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 /**
20  * This generated bean class FieldGroup matches the schema element field-group
21  *
22  * Generated on Thu Sep 25 15:18:26 PDT 2003
23  */

24
25 package org.netbeans.modules.j2ee.sun.sunresources.beans;
26
27 import org.w3c.dom.*;
28 import org.netbeans.modules.schema2beans.*;
29 import java.beans.*;
30 import java.util.*;
31
32 // BEGIN_NOI18N
33

34 public class FieldGroup extends org.netbeans.modules.schema2beans.BaseBean
35 {
36
37     static Vector comparators = new Vector();
38
39     static public final String JavaDoc NAME = "Name"; // NOI18N
40
static public final String JavaDoc FIELD = "Field"; // NOI18N
41

42     public FieldGroup() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public FieldGroup(int options)
47     {
48         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
49         // Properties (see root bean comments for the bean graph)
50
this.createProperty("name", // NOI18N
51
NAME,
52             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
53             String JavaDoc.class);
54         this.createProperty("field", // NOI18N
55
FIELD,
56             Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY,
57             Field.class);
58         this.createAttribute(FIELD, "field-type", "FieldType",
59                         AttrProp.CDATA,
60                         null, "string");
61         this.createAttribute(FIELD, "required", "Required",
62                         AttrProp.CDATA,
63                         null, "true");
64         this.initialize(options);
65     }
66
67     // Setting the default values of the properties
68
void initialize(int options)
69     {
70     
71     }
72
73     // This attribute is mandatory
74
public void setName(String JavaDoc value) {
75         this.setValue(NAME, value);
76     }
77
78     //
79
public String JavaDoc getName() {
80         return (String JavaDoc)this.getValue(NAME);
81     }
82
83     // This attribute is an array containing at least one element
84
public void setField(int index, Field value) {
85         this.setValue(FIELD, index, value);
86     }
87
88     //
89
public Field getField(int index) {
90         return (Field)this.getValue(FIELD, index);
91     }
92
93     // This attribute is an array containing at least one element
94
public void setField(Field[] value) {
95         this.setValue(FIELD, value);
96     }
97
98     //
99
public Field[] getField() {
100         return (Field[])this.getValues(FIELD);
101     }
102
103     // Return the number of properties
104
public int sizeField() {
105         return this.size(FIELD);
106     }
107
108     // Add a new element returning its index in the list
109
public int addField(org.netbeans.modules.j2ee.sun.sunresources.beans.Field value) {
110         return this.addValue(FIELD, value);
111     }
112
113     //
114
// Remove an element using its reference
115
// Returns the index the element had in the list
116
//
117
public int removeField(org.netbeans.modules.j2ee.sun.sunresources.beans.Field value) {
118         return this.removeValue(FIELD, value);
119     }
120
121     //
122
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
123         comparators.add(c);
124     }
125
126     //
127
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
128         comparators.remove(c);
129     }
130     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
131         // Validating property name
132
if (getName() == null) {
133             throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); // NOI18N
134
}
135         // Validating property field
136
if (sizeField() == 0) {
137             throw new org.netbeans.modules.schema2beans.ValidateException("sizeField() == 0", "field", this); // NOI18N
138
}
139         for (int _index = 0; _index < sizeField(); ++_index) {
140             org.netbeans.modules.j2ee.sun.sunresources.beans.Field element = getField(_index);
141             if (element != null) {
142                 element.validate();
143             }
144         }
145     }
146
147     // Dump the content of this bean returning it as a String
148
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
149         String JavaDoc s;
150         org.netbeans.modules.schema2beans.BaseBean n;
151         str.append(indent);
152         str.append("Name"); // NOI18N
153
str.append(indent+"\t"); // NOI18N
154
str.append("<"); // NOI18N
155
s = this.getName();
156         str.append((s==null?"null":s.trim())); // NOI18N
157
str.append(">\n"); // NOI18N
158
this.dumpAttributes(NAME, 0, str, indent);
159
160         str.append(indent);
161         str.append("Field["+this.sizeField()+"]"); // NOI18N
162
for(int i=0; i<this.sizeField(); i++)
163         {
164             str.append(indent+"\t");
165             str.append("#"+i+":");
166             n = (org.netbeans.modules.schema2beans.BaseBean) this.getField(i);
167             if (n != null)
168                 n.dump(str, indent + "\t"); // NOI18N
169
else
170                 str.append(indent+"\tnull"); // NOI18N
171
this.dumpAttributes(FIELD, i, str, indent);
172         }
173
174     }
175     public String JavaDoc dumpBeanNode(){
176         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
177         str.append("FieldGroup\n"); // NOI18N
178
this.dump(str, "\n "); // NOI18N
179
return str.toString();
180     }}
181
182 // END_NOI18N
183

184
185 /*
186         The following schema file has been used for generation:
187
188 <!ELEMENT wizard (name, field-group+)>
189 <!ELEMENT field-group (name, field+)>
190 <!ELEMENT field (name, field-value, tag?)>
191 <!ATTLIST field field-type CDATA "string"
192                  required CDATA "true">
193 <!ELEMENT field-value (default-field-value, option-value-pair*)>
194 <!ELEMENT option-value-pair (option-name, conditional-value)>
195 <!ELEMENT name (#PCDATA)>
196 <!ELEMENT default-field-value (#PCDATA)>
197 <!ELEMENT option-name (#PCDATA)>
198 <!ELEMENT conditional-value (#PCDATA)>
199 <!ELEMENT tag (tag-item*)>
200 <!ELEMENT tag-item (#PCDATA)>
201
202
203
204 */

205
Popular Tags