KickJava   Java API By Example, From Geeks To Geeks.

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


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 Field matches the schema element field
21  *
22  * Generated on Thu Sep 25 15:18:26 PDT 2003
23  */

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

31 public class Field extends org.netbeans.modules.schema2beans.BaseBean
32 {
33
34     static Vector comparators = new Vector();
35
36     static public final String JavaDoc FIELDTYPE = "FieldType"; // NOI18N
37
static public final String JavaDoc REQUIRED = "Required"; // NOI18N
38
static public final String JavaDoc NAME = "Name"; // NOI18N
39
static public final String JavaDoc FIELD_VALUE = "FieldValue"; // NOI18N
40
static public final String JavaDoc TAG = "Tag"; // NOI18N
41

42     public Field() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public Field(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-value", // NOI18N
55
FIELD_VALUE,
56             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
57             FieldValue.class);
58         this.createProperty("tag", // NOI18N
59
TAG,
60             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
61             Tag.class);
62         this.initialize(options);
63     }
64
65     // Setting the default values of the properties
66
void initialize(int options)
67     {
68     
69     }
70
71     // This attribute is mandatory
72
public void setFieldType(java.lang.String JavaDoc value) {
73         setAttributeValue(FIELDTYPE, value);
74     }
75
76     //
77
public java.lang.String JavaDoc getFieldType() {
78         return getAttributeValue(FIELDTYPE);
79     }
80
81     // This attribute is mandatory
82
public void setRequired(java.lang.String JavaDoc value) {
83         setAttributeValue(REQUIRED, value);
84     }
85
86     //
87
public java.lang.String JavaDoc getRequired() {
88         return getAttributeValue(REQUIRED);
89     }
90
91     // This attribute is mandatory
92
public void setName(String JavaDoc value) {
93         this.setValue(NAME, value);
94     }
95
96     //
97
public String JavaDoc getName() {
98         return (String JavaDoc)this.getValue(NAME);
99     }
100
101     // This attribute is mandatory
102
public void setFieldValue(FieldValue value) {
103         this.setValue(FIELD_VALUE, value);
104     }
105
106     //
107
public FieldValue getFieldValue() {
108         return (FieldValue)this.getValue(FIELD_VALUE);
109     }
110
111     // This attribute is optional
112
public void setTag(Tag value) {
113         this.setValue(TAG, value);
114     }
115
116     //
117
public Tag getTag() {
118         return (Tag)this.getValue(TAG);
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 fieldType
132
if (getFieldType() == null) {
133             throw new org.netbeans.modules.schema2beans.ValidateException("getFieldType() == null", "fieldType", this); // NOI18N
134
}
135         // Validating property required
136
if (getRequired() == null) {
137             throw new org.netbeans.modules.schema2beans.ValidateException("getRequired() == null", "required", this); // NOI18N
138
}
139         // Validating property name
140
if (getName() == null) {
141             throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); // NOI18N
142
}
143         // Validating property fieldValue
144
if (getFieldValue() == null) {
145             throw new org.netbeans.modules.schema2beans.ValidateException("getFieldValue() == null", "fieldValue", this); // NOI18N
146
}
147         getFieldValue().validate();
148         // Validating property tag
149
if (getTag() != null) {
150             getTag().validate();
151         }
152     }
153
154     // Dump the content of this bean returning it as a String
155
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
156         String JavaDoc s;
157         org.netbeans.modules.schema2beans.BaseBean n;
158         str.append(indent);
159         str.append("Name"); // NOI18N
160
str.append(indent+"\t"); // NOI18N
161
str.append("<"); // NOI18N
162
s = this.getName();
163         str.append((s==null?"null":s.trim())); // NOI18N
164
str.append(">\n"); // NOI18N
165
this.dumpAttributes(NAME, 0, str, indent);
166
167         str.append(indent);
168         str.append("FieldValue"); // NOI18N
169
n = (org.netbeans.modules.schema2beans.BaseBean) this.getFieldValue();
170         if (n != null)
171             n.dump(str, indent + "\t"); // NOI18N
172
else
173             str.append(indent+"\tnull"); // NOI18N
174
this.dumpAttributes(FIELD_VALUE, 0, str, indent);
175
176         str.append(indent);
177         str.append("Tag"); // NOI18N
178
n = (org.netbeans.modules.schema2beans.BaseBean) this.getTag();
179         if (n != null)
180             n.dump(str, indent + "\t"); // NOI18N
181
else
182             str.append(indent+"\tnull"); // NOI18N
183
this.dumpAttributes(TAG, 0, str, indent);
184
185     }
186     public String JavaDoc dumpBeanNode(){
187         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
188         str.append("Field\n"); // NOI18N
189
this.dump(str, "\n "); // NOI18N
190
return str.toString();
191     }}
192
193 // END_NOI18N
194

195
196 /*
197         The following schema file has been used for generation:
198
199 <!ELEMENT wizard (name, field-group+)>
200 <!ELEMENT field-group (name, field+)>
201 <!ELEMENT field (name, field-value, tag?)>
202 <!ATTLIST field field-type CDATA "string"
203                  required CDATA "true">
204 <!ELEMENT field-value (default-field-value, option-value-pair*)>
205 <!ELEMENT option-value-pair (option-name, conditional-value)>
206 <!ELEMENT name (#PCDATA)>
207 <!ELEMENT default-field-value (#PCDATA)>
208 <!ELEMENT option-name (#PCDATA)>
209 <!ELEMENT conditional-value (#PCDATA)>
210 <!ELEMENT tag (tag-item*)>
211 <!ELEMENT tag-item (#PCDATA)>
212
213
214
215 */

216
Popular Tags