KickJava   Java API By Example, From Geeks To Geeks.

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


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 ObjectEight matches the schema element object-eight
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 ObjectEight 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 CHILD_OBJECT_ONE = "ChildObjectOne"; // NOI18N
42
static public final String JavaDoc CHILD_OBJECT_TWO = "ChildObjectTwo"; // NOI18N
43
static public final String JavaDoc CHILD_OBJECT_THREE = "ChildObjectThree"; // NOI18N
44
static public final String JavaDoc CHILD_OBJECT_FOUR = "ChildObjectFour"; // NOI18N
45

46     public ObjectEight() {
47         this(Common.USE_DEFAULT_VALUES);
48     }
49
50     public ObjectEight(int options)
51     {
52         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
53         // Properties (see root bean comments for the bean graph)
54
this.createProperty("property-one", // NOI18N
55
PROPERTY_ONE,
56             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
57             String JavaDoc.class);
58         this.createProperty("property-two", // NOI18N
59
PROPERTY_TWO,
60             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
61             String JavaDoc.class);
62         this.createProperty("child-object-one", // NOI18N
63
CHILD_OBJECT_ONE,
64             Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
65             ChildObjectOne.class);
66         this.createProperty("child-object-two", // NOI18N
67
CHILD_OBJECT_TWO,
68             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
69             ChildObjectTwo.class);
70         this.createProperty("child-object-three", // NOI18N
71
CHILD_OBJECT_THREE,
72             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
73             ChildObjectThree.class);
74         this.createProperty("child-object-four", // NOI18N
75
CHILD_OBJECT_FOUR,
76             Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY,
77             ChildObjectFour.class);
78         this.initialize(options);
79     }
80
81     // Setting the default values of the properties
82
void initialize(int options)
83     {
84         
85     }
86
87     // This attribute is mandatory
88
public void setPropertyOne(String JavaDoc value) {
89         this.setValue(PROPERTY_ONE, value);
90     }
91
92     //
93
public String JavaDoc getPropertyOne() {
94         return (String JavaDoc)this.getValue(PROPERTY_ONE);
95     }
96
97     // This attribute is optional
98
public void setPropertyTwo(String JavaDoc value) {
99         this.setValue(PROPERTY_TWO, value);
100     }
101
102     //
103
public String JavaDoc getPropertyTwo() {
104         return (String JavaDoc)this.getValue(PROPERTY_TWO);
105     }
106
107     // This attribute is mandatory
108
public void setChildObjectOne(ChildObjectOne value) {
109         this.setValue(CHILD_OBJECT_ONE, value);
110     }
111
112     //
113
public ChildObjectOne getChildObjectOne() {
114         return (ChildObjectOne)this.getValue(CHILD_OBJECT_ONE);
115     }
116
117     // This attribute is optional
118
public void setChildObjectTwo(ChildObjectTwo value) {
119         this.setValue(CHILD_OBJECT_TWO, value);
120     }
121
122     //
123
public ChildObjectTwo getChildObjectTwo() {
124         return (ChildObjectTwo)this.getValue(CHILD_OBJECT_TWO);
125     }
126
127     // This attribute is an array, possibly empty
128
public void setChildObjectThree(int index, ChildObjectThree value) {
129         this.setValue(CHILD_OBJECT_THREE, index, value);
130     }
131
132     //
133
public ChildObjectThree getChildObjectThree(int index) {
134         return (ChildObjectThree)this.getValue(CHILD_OBJECT_THREE, index);
135     }
136
137     // This attribute is an array, possibly empty
138
public void setChildObjectThree(ChildObjectThree[] value) {
139         this.setValue(CHILD_OBJECT_THREE, value);
140     }
141
142     //
143
public ChildObjectThree[] getChildObjectThree() {
144         return (ChildObjectThree[])this.getValues(CHILD_OBJECT_THREE);
145     }
146
147     // Return the number of properties
148
public int sizeChildObjectThree() {
149         return this.size(CHILD_OBJECT_THREE);
150     }
151
152     // Add a new element returning its index in the list
153
public int addChildObjectThree(org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.ChildObjectThree value) {
154         return this.addValue(CHILD_OBJECT_THREE, value);
155     }
156
157     //
158
// Remove an element using its reference
159
// Returns the index the element had in the list
160
//
161
public int removeChildObjectThree(org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.ChildObjectThree value) {
162         return this.removeValue(CHILD_OBJECT_THREE, value);
163     }
164
165     // This attribute is an array containing at least one element
166
public void setChildObjectFour(int index, ChildObjectFour value) {
167         this.setValue(CHILD_OBJECT_FOUR, index, value);
168     }
169
170     //
171
public ChildObjectFour getChildObjectFour(int index) {
172         return (ChildObjectFour)this.getValue(CHILD_OBJECT_FOUR, index);
173     }
174
175     // This attribute is an array containing at least one element
176
public void setChildObjectFour(ChildObjectFour[] value) {
177         this.setValue(CHILD_OBJECT_FOUR, value);
178     }
179
180     //
181
public ChildObjectFour[] getChildObjectFour() {
182         return (ChildObjectFour[])this.getValues(CHILD_OBJECT_FOUR);
183     }
184
185     // Return the number of properties
186
public int sizeChildObjectFour() {
187         return this.size(CHILD_OBJECT_FOUR);
188     }
189
190     // Add a new element returning its index in the list
191
public int addChildObjectFour(org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.ChildObjectFour value) {
192         return this.addValue(CHILD_OBJECT_FOUR, value);
193     }
194
195     //
196
// Remove an element using its reference
197
// Returns the index the element had in the list
198
//
199
public int removeChildObjectFour(org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.ChildObjectFour value) {
200         return this.removeValue(CHILD_OBJECT_FOUR, value);
201     }
202
203     //
204
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
205         comparators.add(c);
206     }
207
208     //
209
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
210         comparators.remove(c);
211     }
212     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
213         boolean restrictionFailure = false;
214         // Validating property propertyOne
215
if (getPropertyOne() == null) {
216             throw new org.netbeans.modules.schema2beans.ValidateException("getPropertyOne() == null", "propertyOne", this); // NOI18N
217
}
218         // Validating property propertyTwo
219
if (getPropertyTwo() != null) {
220         }
221         // Validating property childObjectOne
222
if (getChildObjectOne() == null) {
223             throw new org.netbeans.modules.schema2beans.ValidateException("getChildObjectOne() == null", "childObjectOne", this); // NOI18N
224
}
225         getChildObjectOne().validate();
226         // Validating property childObjectTwo
227
if (getChildObjectTwo() != null) {
228             getChildObjectTwo().validate();
229         }
230         // Validating property childObjectThree
231
for (int _index = 0; _index < sizeChildObjectThree(); ++_index) {
232             org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.ChildObjectThree element = getChildObjectThree(_index);
233             if (element != null) {
234                 element.validate();
235             }
236         }
237         // Validating property childObjectFour
238
if (sizeChildObjectFour() == 0) {
239             throw new org.netbeans.modules.schema2beans.ValidateException("sizeChildObjectFour() == 0", "childObjectFour", this); // NOI18N
240
}
241         for (int _index = 0; _index < sizeChildObjectFour(); ++_index) {
242             org.netbeans.modules.j2ee.sun.validation.samples.simple.beans.ChildObjectFour element = getChildObjectFour(_index);
243             if (element != null) {
244                 element.validate();
245             }
246         }
247     }
248
249     // Dump the content of this bean returning it as a String
250
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
251         String JavaDoc s;
252         Object JavaDoc o;
253         org.netbeans.modules.schema2beans.BaseBean n;
254         str.append(indent);
255         str.append("PropertyOne"); // NOI18N
256
str.append(indent+"\t"); // NOI18N
257
str.append("<"); // NOI18N
258
s = this.getPropertyOne();
259         str.append((s==null?"null":s.trim())); // NOI18N
260
str.append(">\n"); // NOI18N
261
this.dumpAttributes(PROPERTY_ONE, 0, str, indent);
262
263         str.append(indent);
264         str.append("PropertyTwo"); // NOI18N
265
str.append(indent+"\t"); // NOI18N
266
str.append("<"); // NOI18N
267
s = this.getPropertyTwo();
268         str.append((s==null?"null":s.trim())); // NOI18N
269
str.append(">\n"); // NOI18N
270
this.dumpAttributes(PROPERTY_TWO, 0, str, indent);
271
272         str.append(indent);
273         str.append("ChildObjectOne"); // NOI18N
274
n = (org.netbeans.modules.schema2beans.BaseBean) this.getChildObjectOne();
275         if (n != null)
276             n.dump(str, indent + "\t"); // NOI18N
277
else
278             str.append(indent+"\tnull"); // NOI18N
279
this.dumpAttributes(CHILD_OBJECT_ONE, 0, str, indent);
280
281         str.append(indent);
282         str.append("ChildObjectTwo"); // NOI18N
283
n = (org.netbeans.modules.schema2beans.BaseBean) this.getChildObjectTwo();
284         if (n != null)
285             n.dump(str, indent + "\t"); // NOI18N
286
else
287             str.append(indent+"\tnull"); // NOI18N
288
this.dumpAttributes(CHILD_OBJECT_TWO, 0, str, indent);
289
290         str.append(indent);
291         str.append("ChildObjectThree["+this.sizeChildObjectThree()+"]"); // NOI18N
292
for(int i=0; i<this.sizeChildObjectThree(); i++)
293         {
294             str.append(indent+"\t");
295             str.append("#"+i+":");
296             n = (org.netbeans.modules.schema2beans.BaseBean) this.getChildObjectThree(i);
297             if (n != null)
298                 n.dump(str, indent + "\t"); // NOI18N
299
else
300                 str.append(indent+"\tnull"); // NOI18N
301
this.dumpAttributes(CHILD_OBJECT_THREE, i, str, indent);
302         }
303
304         str.append(indent);
305         str.append("ChildObjectFour["+this.sizeChildObjectFour()+"]"); // NOI18N
306
for(int i=0; i<this.sizeChildObjectFour(); i++)
307         {
308             str.append(indent+"\t");
309             str.append("#"+i+":");
310             n = (org.netbeans.modules.schema2beans.BaseBean) this.getChildObjectFour(i);
311             if (n != null)
312                 n.dump(str, indent + "\t"); // NOI18N
313
else
314                 str.append(indent+"\tnull"); // NOI18N
315
this.dumpAttributes(CHILD_OBJECT_FOUR, i, str, indent);
316         }
317
318     }
319     public String JavaDoc dumpBeanNode(){
320         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
321         str.append("ObjectEight\n"); // NOI18N
322
this.dump(str, "\n "); // NOI18N
323
return str.toString();
324     }}
325
326 // END_NOI18N
327

328
329 /*
330         The following schema file has been used for generation:
331
332 <?xml version="1.0" encoding="UTF-8"?>
333 <!--
334     Document : sample.dtd
335     Created on : May 8, 2003, 11:18 AM
336     Author : Rajeshwar Patil
337     Description:
338         Purpose of the document follows.
339 -->
340
341 <!--
342 -->
343 <!ELEMENT root-element (non-zero-length-property, number-property+,
344     boolean-property*, range-property?, enumeration-property,
345     object-one, object-two?, object-three?, object-four,
346     object-five*, object-six+, object-seven*,object-eight*)>
347
348 <!--
349 -->
350 <!ELEMENT object-one (property-one, property-two?)>
351
352
353 <!--
354 -->
355 <!ELEMENT object-two (property-one, property-two)>
356
357
358 <!--
359 -->
360 <!ELEMENT object-three (property-one, property-two?,
361     property-three+, property-four*)>
362
363
364 <!--
365 -->
366 <!ELEMENT object-four (property-one?, property-two?)>
367
368
369 <!--
370 -->
371 <!ELEMENT object-five (property-one, property-two?)>
372
373
374 <!--
375 -->
376 <!ELEMENT object-six (property-one?, property-two?)>
377
378
379 <!--
380 -->
381 <!ELEMENT object-seven (property-one, property-two)>
382
383
384 <!--
385 -->
386 <!ELEMENT object-eight (property-one, property-two?, child-object-one,
387     child-object-two?, child-object-three*, child-object-four+)>
388
389
390 <!--
391 -->
392 <!ELEMENT child-object-one (property-one, property-two?)>
393
394
395 <!--
396 -->
397 <!ELEMENT child-object-two (property-one, property-two)>
398
399
400 <!--
401 -->
402 <!ELEMENT child-object-three (property-one?, property-two?)>
403
404
405 <!--
406 -->
407 <!ELEMENT child-object-four (property-one, property-two?,
408     property-three+, property-four*)>
409
410
411 <!ELEMENT boolean-property (#PCDATA)>
412 <!ELEMENT number-property (#PCDATA)>
413 <!ELEMENT non-zero-length-property (#PCDATA)>
414 <!ELEMENT range-property (#PCDATA)>
415 <!ELEMENT enumeration-property (#PCDATA)>
416 <!ELEMENT property-one (#PCDATA)>
417 <!ELEMENT property-two (#PCDATA)>
418 <!ELEMENT property-three (#PCDATA)>
419 <!ELEMENT property-four (#PCDATA)>
420
421 */

422
Popular Tags