KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > validation > data > Element


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 Element matches the schema element element
22  *
23  */

24
25 package org.netbeans.modules.j2ee.sun.validation.data;
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 Element extends org.netbeans.modules.schema2beans.BaseBean
35 {
36
37     static Vector comparators = new Vector();
38
39     static public final String JavaDoc NAME = "Name"; // NOI18N
40
static public final String JavaDoc CHECK = "Check"; // NOI18N
41

42     public Element() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public Element(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("name", // NOI18N
51
NAME,
52             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
53             String JavaDoc.class);
54         this.createProperty("check", // NOI18N
55
CHECK,
56             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
57             Check.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 setName(String JavaDoc value) {
69         this.setValue(NAME, value);
70     }
71
72     //
73
public String JavaDoc getName() {
74         return (String JavaDoc)this.getValue(NAME);
75     }
76
77     // This attribute is an array, possibly empty
78
public void setCheck(int index, Check value) {
79         this.setValue(CHECK, index, value);
80     }
81
82     //
83
public Check getCheck(int index) {
84         return (Check)this.getValue(CHECK, index);
85     }
86
87     // This attribute is an array, possibly empty
88
public void setCheck(Check[] value) {
89         this.setValue(CHECK, value);
90     }
91
92     //
93
public Check[] getCheck() {
94         return (Check[])this.getValues(CHECK);
95     }
96
97     // Return the number of properties
98
public int sizeCheck() {
99         return this.size(CHECK);
100     }
101
102     // Add a new element returning its index in the list
103
public int addCheck(org.netbeans.modules.j2ee.sun.validation.data.Check value) {
104         return this.addValue(CHECK, value);
105     }
106
107     //
108
// Remove an element using its reference
109
// Returns the index the element had in the list
110
//
111
public int removeCheck(org.netbeans.modules.j2ee.sun.validation.data.Check value) {
112         return this.removeValue(CHECK, value);
113     }
114
115     //
116
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
117         comparators.add(c);
118     }
119
120     //
121
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
122         comparators.remove(c);
123     }
124     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
125         boolean restrictionFailure = false;
126         // Validating property name
127
if (getName() == null) {
128             throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); // NOI18N
129
}
130         // Validating property check
131
for (int _index = 0; _index < sizeCheck(); ++_index) {
132             org.netbeans.modules.j2ee.sun.validation.data.Check element = getCheck(_index);
133             if (element != null) {
134                 element.validate();
135             }
136         }
137     }
138
139     // Dump the content of this bean returning it as a String
140
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
141         String JavaDoc s;
142         Object JavaDoc o;
143         org.netbeans.modules.schema2beans.BaseBean n;
144         str.append(indent);
145         str.append("Name"); // NOI18N
146
str.append(indent+"\t"); // NOI18N
147
str.append("<"); // NOI18N
148
s = this.getName();
149         str.append((s==null?"null":s.trim())); // NOI18N
150
str.append(">\n"); // NOI18N
151
this.dumpAttributes(NAME, 0, str, indent);
152
153         str.append(indent);
154         str.append("Check["+this.sizeCheck()+"]"); // NOI18N
155
for(int i=0; i<this.sizeCheck(); i++)
156         {
157             str.append(indent+"\t");
158             str.append("#"+i+":");
159             n = (org.netbeans.modules.schema2beans.BaseBean) this.getCheck(i);
160             if (n != null)
161                 n.dump(str, indent + "\t"); // NOI18N
162
else
163                 str.append(indent+"\tnull"); // NOI18N
164
this.dumpAttributes(CHECK, i, str, indent);
165         }
166
167     }
168     public String JavaDoc dumpBeanNode(){
169         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
170         str.append("Element\n"); // NOI18N
171
this.dump(str, "\n "); // NOI18N
172
return str.toString();
173     }}
174
175 // END_NOI18N
176

177
178 /*
179         The following schema file has been used for generation:
180
181 <!--
182   XML DTD for for validation xml.
183   validation.xml is used to specify Constraints to be applied to
184   elements.
185  
186   $Revision: 1.2 $
187 -->
188
189
190 <!--
191 This is the root element
192 -->
193 <!ELEMENT validation (element*) >
194 <!ATTLIST validation
195         validate CDATA (true | false) "true">
196
197
198 <!--
199 This element represents, the set of Constraints to be applied to
200 the given element.
201 -->
202 <!ELEMENT element (name, check*)>
203
204
205 <!--
206 This element represents, a particular Constraint.
207 Note : Information about this Constraint must be provided through
208 corresponding <check-info> object in constraints.xml Sub element
209 <name> should match with <name> of corresponding <check-info>
210 element defined in constraints.xml.
211 -->
212 <!ELEMENT check (name, parameters?)>
213
214
215 <!--
216 This element represent, Constraint parameters.
217 Number of sub elements, <parameter> should match with the number
218 of <argument> sub elements, of corresponding <arguments> element
219 in constraints.xml
220 -->
221 <!ELEMENT parameters (parameter+)>
222
223
224 <!--
225 This element represents, a Constraint parameter.
226 Sub elements <name> should match with the <name> sub element of
227 corresponding <argument> element in constraints.xml
228 <value> could be one or more. In case of an variable array
229 argument, multiple <value> elements will be used.
230 Example : InConstraint
231 -->
232 <!ELEMENT parameter (name, value+)>
233
234
235 <!--
236 Used in elements : <element>, <check> and <parameter>
237 In <element> , it represents the name(xpath - complete absolute
238 name of an element(leaf).
239 In <check> , it represents name of a Constraint. This is the
240 linking element for <check> element in validation.xml and
241 <check-info> element in constraints.xml.
242 In <parameter>, it represents name of parameter. This is the
243 linking element for <parameter> element in validation.xml and
244 <argument> element in constraints.xml.
245 -->
246 <!ELEMENT name (#PCDATA)>
247
248
249 <!--
250 This element represents the value of a parameter.
251 -->
252 <!ELEMENT value (#PCDATA)>
253
254 */

255
Popular Tags