KickJava   Java API By Example, From Geeks To Geeks.

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


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 ObjectSeven matches the schema element object-seven
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 ObjectSeven 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

42     public ObjectSeven() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public ObjectSeven(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("property-one", // NOI18N
51
PROPERTY_ONE,
52             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
53             String JavaDoc.class);
54         this.createProperty("property-two", // NOI18N
55
PROPERTY_TWO,
56             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
57             String JavaDoc.class);
58         this.initialize(options);
59     }
60
61     // Setting the default values of the properties
62
void initialize(int options)
63     {
64         
65     }
66
67     // This attribute is mandatory
68
public void setPropertyOne(String JavaDoc value) {
69         this.setValue(PROPERTY_ONE, value);
70     }
71
72     //
73
public String JavaDoc getPropertyOne() {
74         return (String JavaDoc)this.getValue(PROPERTY_ONE);
75     }
76
77     // This attribute is mandatory
78
public void setPropertyTwo(String JavaDoc value) {
79         this.setValue(PROPERTY_TWO, value);
80     }
81
82     //
83
public String JavaDoc getPropertyTwo() {
84         return (String JavaDoc)this.getValue(PROPERTY_TWO);
85     }
86
87     //
88
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
89         comparators.add(c);
90     }
91
92     //
93
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
94         comparators.remove(c);
95     }
96     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
97         boolean restrictionFailure = false;
98         // Validating property propertyOne
99
if (getPropertyOne() == null) {
100             throw new org.netbeans.modules.schema2beans.ValidateException("getPropertyOne() == null", "propertyOne", this); // NOI18N
101
}
102         // Validating property propertyTwo
103
if (getPropertyTwo() == null) {
104             throw new org.netbeans.modules.schema2beans.ValidateException("getPropertyTwo() == null", "propertyTwo", this); // NOI18N
105
}
106     }
107
108     // Dump the content of this bean returning it as a String
109
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
110         String JavaDoc s;
111         Object JavaDoc o;
112         org.netbeans.modules.schema2beans.BaseBean n;
113         str.append(indent);
114         str.append("PropertyOne"); // NOI18N
115
str.append(indent+"\t"); // NOI18N
116
str.append("<"); // NOI18N
117
s = this.getPropertyOne();
118         str.append((s==null?"null":s.trim())); // NOI18N
119
str.append(">\n"); // NOI18N
120
this.dumpAttributes(PROPERTY_ONE, 0, str, indent);
121
122         str.append(indent);
123         str.append("PropertyTwo"); // NOI18N
124
str.append(indent+"\t"); // NOI18N
125
str.append("<"); // NOI18N
126
s = this.getPropertyTwo();
127         str.append((s==null?"null":s.trim())); // NOI18N
128
str.append(">\n"); // NOI18N
129
this.dumpAttributes(PROPERTY_TWO, 0, str, indent);
130
131     }
132     public String JavaDoc dumpBeanNode(){
133         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
134         str.append("ObjectSeven\n"); // NOI18N
135
this.dump(str, "\n "); // NOI18N
136
return str.toString();
137     }}
138
139 // END_NOI18N
140

141
142 /*
143         The following schema file has been used for generation:
144
145 <?xml version="1.0" encoding="UTF-8"?>
146 <!--
147     Document : sample.dtd
148     Created on : May 8, 2003, 11:18 AM
149     Author : Rajeshwar Patil
150     Description:
151         Purpose of the document follows.
152 -->
153
154 <!--
155 -->
156 <!ELEMENT root-element (non-zero-length-property, number-property+,
157     boolean-property*, range-property?, enumeration-property,
158     object-one, object-two?, object-three?, object-four,
159     object-five*, object-six+, object-seven*,object-eight*)>
160
161 <!--
162 -->
163 <!ELEMENT object-one (property-one, property-two?)>
164
165
166 <!--
167 -->
168 <!ELEMENT object-two (property-one, property-two)>
169
170
171 <!--
172 -->
173 <!ELEMENT object-three (property-one, property-two?,
174     property-three+, property-four*)>
175
176
177 <!--
178 -->
179 <!ELEMENT object-four (property-one?, property-two?)>
180
181
182 <!--
183 -->
184 <!ELEMENT object-five (property-one, property-two?)>
185
186
187 <!--
188 -->
189 <!ELEMENT object-six (property-one?, property-two?)>
190
191
192 <!--
193 -->
194 <!ELEMENT object-seven (property-one, property-two)>
195
196
197 <!--
198 -->
199 <!ELEMENT object-eight (property-one, property-two?, child-object-one,
200     child-object-two?, child-object-three*, child-object-four+)>
201
202
203 <!--
204 -->
205 <!ELEMENT child-object-one (property-one, property-two?)>
206
207
208 <!--
209 -->
210 <!ELEMENT child-object-two (property-one, property-two)>
211
212
213 <!--
214 -->
215 <!ELEMENT child-object-three (property-one?, property-two?)>
216
217
218 <!--
219 -->
220 <!ELEMENT child-object-four (property-one, property-two?,
221     property-three+, property-four*)>
222
223
224 <!ELEMENT boolean-property (#PCDATA)>
225 <!ELEMENT number-property (#PCDATA)>
226 <!ELEMENT non-zero-length-property (#PCDATA)>
227 <!ELEMENT range-property (#PCDATA)>
228 <!ELEMENT enumeration-property (#PCDATA)>
229 <!ELEMENT property-one (#PCDATA)>
230 <!ELEMENT property-two (#PCDATA)>
231 <!ELEMENT property-three (#PCDATA)>
232 <!ELEMENT property-four (#PCDATA)>
233
234 */

235
Popular Tags