KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > validation > samples > simple > beans > ObjectThree


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 /**
21  * This generated bean class ObjectThree matches the schema element object-three
22  *
23  */

24
25 package org.netbeans.modules.j2ee.sun.validation.samples.simple.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 ObjectThree extends org.netbeans.modules.schema2beans.BaseBean
35 {
36
37     static Vector comparators = new Vector();
38
39     static public final String JavaDoc PROPERTY_ONE = "PropertyOne"; // NOI18N
40
static public final String JavaDoc PROPERTY_TWO = "PropertyTwo"; // NOI18N
41
static public final String JavaDoc PROPERTY_THREE = "PropertyThree"; // NOI18N
42
static public final String JavaDoc PROPERTY_FOUR = "PropertyFour"; // NOI18N
43

44     public ObjectThree() {
45         this(Common.USE_DEFAULT_VALUES);
46     }
47
48     public ObjectThree(int options)
49     {
50         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
51         // Properties (see root bean comments for the bean graph)
52
this.createProperty("property-one", // NOI18N
53
PROPERTY_ONE,
54             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
55             String JavaDoc.class);
56         this.createProperty("property-two", // NOI18N
57
PROPERTY_TWO,
58             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
59             String JavaDoc.class);
60         this.createProperty("property-three", // NOI18N
61
PROPERTY_THREE,
62             Common.TYPE_1_N | Common.TYPE_STRING | Common.TYPE_KEY,
63             String JavaDoc.class);
64         this.createProperty("property-four", // NOI18N
65
PROPERTY_FOUR,
66             Common.TYPE_0_N | Common.TYPE_STRING | Common.TYPE_KEY,
67             String JavaDoc.class);
68         this.initialize(options);
69     }
70
71     // Setting the default values of the properties
72
void initialize(int options)
73     {
74                 
75     }
76
77     // This attribute is mandatory
78
public void setPropertyOne(String JavaDoc value) {
79         this.setValue(PROPERTY_ONE, value);
80     }
81
82     //
83
public String JavaDoc getPropertyOne() {
84         return (String JavaDoc)this.getValue(PROPERTY_ONE);
85     }
86
87     // This attribute is optional
88
public void setPropertyTwo(String JavaDoc value) {
89         this.setValue(PROPERTY_TWO, value);
90     }
91
92     //
93
public String JavaDoc getPropertyTwo() {
94         return (String JavaDoc)this.getValue(PROPERTY_TWO);
95     }
96
97     // This attribute is an array containing at least one element
98
public void setPropertyThree(int index, String JavaDoc value) {
99         this.setValue(PROPERTY_THREE, index, value);
100     }
101
102     //
103
public String JavaDoc getPropertyThree(int index) {
104         return (String JavaDoc)this.getValue(PROPERTY_THREE, index);
105     }
106
107     // This attribute is an array containing at least one element
108
public void setPropertyThree(String JavaDoc[] value) {
109         this.setValue(PROPERTY_THREE, value);
110     }
111
112     //
113
public String JavaDoc[] getPropertyThree() {
114         return (String JavaDoc[])this.getValues(PROPERTY_THREE);
115     }
116
117     // Return the number of properties
118
public int sizePropertyThree() {
119         return this.size(PROPERTY_THREE);
120     }
121
122     // Add a new element returning its index in the list
123
public int addPropertyThree(String JavaDoc value) {
124         return this.addValue(PROPERTY_THREE, value);
125     }
126
127     //
128
// Remove an element using its reference
129
// Returns the index the element had in the list
130
//
131
public int removePropertyThree(String JavaDoc value) {
132         return this.removeValue(PROPERTY_THREE, value);
133     }
134
135     // This attribute is an array, possibly empty
136
public void setPropertyFour(int index, String JavaDoc value) {
137         this.setValue(PROPERTY_FOUR, index, value);
138     }
139
140     //
141
public String JavaDoc getPropertyFour(int index) {
142         return (String JavaDoc)this.getValue(PROPERTY_FOUR, index);
143     }
144
145     // This attribute is an array, possibly empty
146
public void setPropertyFour(String JavaDoc[] value) {
147         this.setValue(PROPERTY_FOUR, value);
148     }
149
150     //
151
public String JavaDoc[] getPropertyFour() {
152         return (String JavaDoc[])this.getValues(PROPERTY_FOUR);
153     }
154
155     // Return the number of properties
156
public int sizePropertyFour() {
157         return this.size(PROPERTY_FOUR);
158     }
159
160     // Add a new element returning its index in the list
161
public int addPropertyFour(String JavaDoc value) {
162         return this.addValue(PROPERTY_FOUR, value);
163     }
164
165     //
166
// Remove an element using its reference
167
// Returns the index the element had in the list
168
//
169
public int removePropertyFour(String JavaDoc value) {
170         return this.removeValue(PROPERTY_FOUR, value);
171     }
172
173     //
174
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
175         comparators.add(c);
176     }
177
178     //
179
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
180         comparators.remove(c);
181     }
182     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
183         boolean restrictionFailure = false;
184         // Validating property propertyOne
185
if (getPropertyOne() == null) {
186             throw new org.netbeans.modules.schema2beans.ValidateException("getPropertyOne() == null", "propertyOne", this); // NOI18N
187
}
188         // Validating property propertyTwo
189
if (getPropertyTwo() != null) {
190         }
191         // Validating property propertyThree
192
if (sizePropertyThree() == 0) {
193             throw new org.netbeans.modules.schema2beans.ValidateException("sizePropertyThree() == 0", "propertyThree", this); // NOI18N
194
}
195         for (int _index = 0; _index < sizePropertyThree(); ++_index) {
196             String JavaDoc element = getPropertyThree(_index);
197             if (element != null) {
198             }
199         }
200         // Validating property propertyFour
201
for (int _index = 0; _index < sizePropertyFour(); ++_index) {
202             String JavaDoc element = getPropertyFour(_index);
203             if (element != null) {
204             }
205         }
206     }
207
208     // Dump the content of this bean returning it as a String
209
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
210         String JavaDoc s;
211         Object JavaDoc o;
212         org.netbeans.modules.schema2beans.BaseBean n;
213         str.append(indent);
214         str.append("PropertyOne"); // NOI18N
215
str.append(indent+"\t"); // NOI18N
216
str.append("<"); // NOI18N
217
s = this.getPropertyOne();
218         str.append((s==null?"null":s.trim())); // NOI18N
219
str.append(">\n"); // NOI18N
220
this.dumpAttributes(PROPERTY_ONE, 0, str, indent);
221
222         str.append(indent);
223         str.append("PropertyTwo"); // NOI18N
224
str.append(indent+"\t"); // NOI18N
225
str.append("<"); // NOI18N
226
s = this.getPropertyTwo();
227         str.append((s==null?"null":s.trim())); // NOI18N
228
str.append(">\n"); // NOI18N
229
this.dumpAttributes(PROPERTY_TWO, 0, str, indent);
230
231         str.append(indent);
232         str.append("PropertyThree["+this.sizePropertyThree()+"]"); // NOI18N
233
for(int i=0; i<this.sizePropertyThree(); i++)
234         {
235             str.append(indent+"\t");
236             str.append("#"+i+":");
237             str.append(indent+"\t"); // NOI18N
238
str.append("<"); // NOI18N
239
s = this.getPropertyThree(i);
240             str.append((s==null?"null":s.trim())); // NOI18N
241
str.append(">\n"); // NOI18N
242
this.dumpAttributes(PROPERTY_THREE, i, str, indent);
243         }
244
245         str.append(indent);
246         str.append("PropertyFour["+this.sizePropertyFour()+"]"); // NOI18N
247
for(int i=0; i<this.sizePropertyFour(); i++)
248         {
249             str.append(indent+"\t");
250             str.append("#"+i+":");
251             str.append(indent+"\t"); // NOI18N
252
str.append("<"); // NOI18N
253
s = this.getPropertyFour(i);
254             str.append((s==null?"null":s.trim())); // NOI18N
255
str.append(">\n"); // NOI18N
256
this.dumpAttributes(PROPERTY_FOUR, i, str, indent);
257         }
258
259     }
260     public String JavaDoc dumpBeanNode(){
261         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
262         str.append("ObjectThree\n"); // NOI18N
263
this.dump(str, "\n "); // NOI18N
264
return str.toString();
265     }}
266
267 // END_NOI18N
268

269
270 /*
271         The following schema file has been used for generation:
272
273 <?xml version="1.0" encoding="UTF-8"?>
274 <!--
275     Document : sample.dtd
276     Created on : May 8, 2003, 11:18 AM
277     Author : Rajeshwar Patil
278     Description:
279         Purpose of the document follows.
280 -->
281
282 <!--
283 -->
284 <!ELEMENT root-element (non-zero-length-property, number-property+,
285     boolean-property*, range-property?, enumeration-property,
286     object-one, object-two?, object-three?, object-four,
287     object-five*, object-six+, object-seven*,object-eight*)>
288
289 <!--
290 -->
291 <!ELEMENT object-one (property-one, property-two?)>
292
293
294 <!--
295 -->
296 <!ELEMENT object-two (property-one, property-two)>
297
298
299 <!--
300 -->
301 <!ELEMENT object-three (property-one, property-two?,
302     property-three+, property-four*)>
303
304
305 <!--
306 -->
307 <!ELEMENT object-four (property-one?, property-two?)>
308
309
310 <!--
311 -->
312 <!ELEMENT object-five (property-one, property-two?)>
313
314
315 <!--
316 -->
317 <!ELEMENT object-six (property-one?, property-two?)>
318
319
320 <!--
321 -->
322 <!ELEMENT object-seven (property-one, property-two)>
323
324
325 <!--
326 -->
327 <!ELEMENT object-eight (property-one, property-two?, child-object-one,
328     child-object-two?, child-object-three*, child-object-four+)>
329
330
331 <!--
332 -->
333 <!ELEMENT child-object-one (property-one, property-two?)>
334
335
336 <!--
337 -->
338 <!ELEMENT child-object-two (property-one, property-two)>
339
340
341 <!--
342 -->
343 <!ELEMENT child-object-three (property-one?, property-two?)>
344
345
346 <!--
347 -->
348 <!ELEMENT child-object-four (property-one, property-two?,
349     property-three+, property-four*)>
350
351
352 <!ELEMENT boolean-property (#PCDATA)>
353 <!ELEMENT number-property (#PCDATA)>
354 <!ELEMENT non-zero-length-property (#PCDATA)>
355 <!ELEMENT range-property (#PCDATA)>
356 <!ELEMENT enumeration-property (#PCDATA)>
357 <!ELEMENT property-one (#PCDATA)>
358 <!ELEMENT property-two (#PCDATA)>
359 <!ELEMENT property-three (#PCDATA)>
360 <!ELEMENT property-four (#PCDATA)>
361
362 */

363
Popular Tags