KickJava   Java API By Example, From Geeks To Geeks.

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


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 ObjectOne matches the schema element object-one
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 ObjectOne 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 ObjectOne() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public ObjectOne(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_0_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 optional
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         }
105     }
106
107     // Dump the content of this bean returning it as a String
108
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
109         String JavaDoc s;
110         Object JavaDoc o;
111         org.netbeans.modules.schema2beans.BaseBean n;
112         str.append(indent);
113         str.append("PropertyOne"); // NOI18N
114
str.append(indent+"\t"); // NOI18N
115
str.append("<"); // NOI18N
116
s = this.getPropertyOne();
117         str.append((s==null?"null":s.trim())); // NOI18N
118
str.append(">\n"); // NOI18N
119
this.dumpAttributes(PROPERTY_ONE, 0, str, indent);
120
121         str.append(indent);
122         str.append("PropertyTwo"); // NOI18N
123
str.append(indent+"\t"); // NOI18N
124
str.append("<"); // NOI18N
125
s = this.getPropertyTwo();
126         str.append((s==null?"null":s.trim())); // NOI18N
127
str.append(">\n"); // NOI18N
128
this.dumpAttributes(PROPERTY_TWO, 0, str, indent);
129
130     }
131     public String JavaDoc dumpBeanNode(){
132         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
133         str.append("ObjectOne\n"); // NOI18N
134
this.dump(str, "\n "); // NOI18N
135
return str.toString();
136     }}
137
138 // END_NOI18N
139

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

234
Popular Tags