KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > multiview > test > bookmodel > Chapter


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 Chapter matches the schema element 'chapter'.
21  * The root bean class is Book
22  *
23  * Generated on Wed Mar 09 17:37:54 CET 2005
24  * @Generated
25  */

26
27 package org.netbeans.modules.xml.multiview.test.bookmodel;
28
29 import org.w3c.dom.*;
30 import org.netbeans.modules.schema2beans.*;
31 import java.beans.*;
32 import java.util.*;
33
34 // BEGIN_NOI18N
35

36 public class Chapter extends org.netbeans.modules.schema2beans.BaseBean
37 {
38
39     static Vector comparators = new Vector();
40     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 0, 0);
41
42     static public final String JavaDoc TITLE = "Title"; // NOI18N
43
static public final String JavaDoc SUMMARY = "Summary"; // NOI18N
44
static public final String JavaDoc PARAGRAPH = "Paragraph"; // NOI18N
45

46     public Chapter() {
47         this(Common.USE_DEFAULT_VALUES);
48     }
49
50     public Chapter(int options)
51     {
52         super(comparators, runtimeVersion);
53         // Properties (see root bean comments for the bean graph)
54
initPropertyTables(3);
55         this.createProperty("title", // NOI18N
56
TITLE,
57             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
58             String JavaDoc.class);
59         this.createAttribute(TITLE, "lang", "Lang",
60                         AttrProp.CDATA | AttrProp.FIXED,
61                         null, "en");
62         this.createProperty("summary", // NOI18N
63
SUMMARY,
64             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
65             String JavaDoc.class);
66         this.createProperty("paragraph", // NOI18N
67
PARAGRAPH,
68             Common.TYPE_0_N | Common.TYPE_STRING | Common.TYPE_KEY,
69             String JavaDoc.class);
70         this.initialize(options);
71     }
72
73     // Setting the default values of the properties
74
void initialize(int options) {
75
76     }
77
78     // This attribute is mandatory
79
public void setTitle(String JavaDoc value) {
80         this.setValue(TITLE, value);
81     }
82
83     //
84
public String JavaDoc getTitle() {
85         return (String JavaDoc)this.getValue(TITLE);
86     }
87
88     // This attribute is optional
89
public void setSummary(String JavaDoc value) {
90         this.setValue(SUMMARY, value);
91     }
92
93     //
94
public String JavaDoc getSummary() {
95         return (String JavaDoc)this.getValue(SUMMARY);
96     }
97
98     // This attribute is an array, possibly empty
99
public void setParagraph(int index, String JavaDoc value) {
100         this.setValue(PARAGRAPH, index, value);
101     }
102
103     //
104
public String JavaDoc getParagraph(int index) {
105         return (String JavaDoc)this.getValue(PARAGRAPH, index);
106     }
107
108     // Return the number of properties
109
public int sizeParagraph() {
110         return this.size(PARAGRAPH);
111     }
112
113     // This attribute is an array, possibly empty
114
public void setParagraph(String JavaDoc[] value) {
115         this.setValue(PARAGRAPH, value);
116     }
117
118     //
119
public String JavaDoc[] getParagraph() {
120         return (String JavaDoc[])this.getValues(PARAGRAPH);
121     }
122
123     // Add a new element returning its index in the list
124
public int addParagraph(String JavaDoc value) {
125         int positionOfNewItem = this.addValue(PARAGRAPH, value);
126         return positionOfNewItem;
127     }
128
129     //
130
// Remove an element using its reference
131
// Returns the index the element had in the list
132
//
133
public int removeParagraph(String JavaDoc value) {
134         return this.removeValue(PARAGRAPH, value);
135     }
136
137     //
138
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
139         comparators.add(c);
140     }
141
142     //
143
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
144         comparators.remove(c);
145     }
146     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
147         boolean restrictionFailure = false;
148         boolean restrictionPassed = false;
149         // Validating property title
150
if (getTitle() == null) {
151             throw new org.netbeans.modules.schema2beans.ValidateException("getTitle() == null", org.netbeans.modules.schema2beans.ValidateException.FailureType.NULL_VALUE, "title", this); // NOI18N
152
}
153         // Validating property summary
154
// Validating property paragraph
155
}
156
157     // Dump the content of this bean returning it as a String
158
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
159         String JavaDoc s;
160         Object JavaDoc o;
161         org.netbeans.modules.schema2beans.BaseBean n;
162         str.append(indent);
163         str.append("Title"); // NOI18N
164
str.append(indent+"\t"); // NOI18N
165
str.append("<"); // NOI18N
166
o = this.getTitle();
167         str.append((o==null?"null":o.toString().trim())); // NOI18N
168
str.append(">\n"); // NOI18N
169
this.dumpAttributes(TITLE, 0, str, indent);
170
171         str.append(indent);
172         str.append("Summary"); // NOI18N
173
str.append(indent+"\t"); // NOI18N
174
str.append("<"); // NOI18N
175
o = this.getSummary();
176         str.append((o==null?"null":o.toString().trim())); // NOI18N
177
str.append(">\n"); // NOI18N
178
this.dumpAttributes(SUMMARY, 0, str, indent);
179
180         str.append(indent);
181         str.append("Paragraph["+this.sizeParagraph()+"]"); // NOI18N
182
for(int i=0; i<this.sizeParagraph(); i++)
183         {
184             str.append(indent+"\t");
185             str.append("#"+i+":");
186             str.append(indent+"\t"); // NOI18N
187
str.append("<"); // NOI18N
188
o = this.getParagraph(i);
189             str.append((o==null?"null":o.toString().trim())); // NOI18N
190
str.append(">\n"); // NOI18N
191
this.dumpAttributes(PARAGRAPH, i, str, indent);
192         }
193
194     }
195     public String JavaDoc dumpBeanNode(){
196         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
197         str.append("Chapter\n"); // NOI18N
198
this.dump(str, "\n "); // NOI18N
199
return str.toString();
200     }}
201
202 // END_NOI18N
203

204
205 /*
206         The following schema file has been used for generation:
207
208 <!ELEMENT book (title, chapter+, paperback?, price?) >
209 <!ELEMENT title (#PCDATA) >
210 <!ELEMENT chapter ( title, summary?, paragraph* ) >
211 <!ELEMENT summary (#PCDATA) >
212 <!ELEMENT paragraph (#PCDATA) >
213 <!ELEMENT paperback EMPTY >
214 <!ELEMENT price (#PCDATA) >
215 <!ATTLIST book instock (yes | no) "yes" >
216 <!ATTLIST title lang CDATA #FIXED "en" >
217 <!ATTLIST chapter length CDATA #IMPLIED >
218
219 */

220
Popular Tags