KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > common > validation > data > Element


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * This generated bean class Element matches the schema element element
26  *
27  * Generated on Wed Aug 20 17:21:25 PDT 2003
28  */

29
30 package com.sun.enterprise.tools.common.validation.data;
31
32 import org.w3c.dom.*;
33 import org.netbeans.modules.schema2beans.*;
34 import java.beans.*;
35 import java.util.*;
36
37 // BEGIN_NOI18N
38

39 public class Element extends org.netbeans.modules.schema2beans.BaseBean
40 {
41
42     static Vector comparators = new Vector();
43
44     static public final String JavaDoc NAME = "Name"; // NOI18N
45
static public final String JavaDoc CHECK = "Check"; // NOI18N
46

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

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

260
Popular Tags