KickJava   Java API By Example, From Geeks To Geeks.

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


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 Check matches the schema element check
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 Check 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 PARAMETERS = "Parameters"; // NOI18N
41

42     public Check() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public Check(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("parameters", // NOI18N
55
PARAMETERS,
56             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
57             Parameters.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 optional
78
public void setParameters(Parameters value) {
79         this.setValue(PARAMETERS, value);
80     }
81
82     //
83
public Parameters getParameters() {
84         return (Parameters)this.getValue(PARAMETERS);
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 name
99
if (getName() == null) {
100             throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); // NOI18N
101
}
102         // Validating property parameters
103
if (getParameters() != null) {
104             getParameters().validate();
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("Name"); // NOI18N
115
str.append(indent+"\t"); // NOI18N
116
str.append("<"); // NOI18N
117
s = this.getName();
118         str.append((s==null?"null":s.trim())); // NOI18N
119
str.append(">\n"); // NOI18N
120
this.dumpAttributes(NAME, 0, str, indent);
121
122         str.append(indent);
123         str.append("Parameters"); // NOI18N
124
n = (org.netbeans.modules.schema2beans.BaseBean) this.getParameters();
125         if (n != null)
126             n.dump(str, indent + "\t"); // NOI18N
127
else
128             str.append(indent+"\tnull"); // NOI18N
129
this.dumpAttributes(PARAMETERS, 0, str, indent);
130
131     }
132     public String JavaDoc dumpBeanNode(){
133         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
134         str.append("Check\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 <!--
146   XML DTD for for validation xml.
147   validation.xml is used to specify Constraints to be applied to
148   elements.
149  
150   $Revision: 1.2 $
151 -->
152
153
154 <!--
155 This is the root element
156 -->
157 <!ELEMENT validation (element*) >
158 <!ATTLIST validation
159         validate CDATA (true | false) "true">
160
161
162 <!--
163 This element represents, the set of Constraints to be applied to
164 the given element.
165 -->
166 <!ELEMENT element (name, check*)>
167
168
169 <!--
170 This element represents, a particular Constraint.
171 Note : Information about this Constraint must be provided through
172 corresponding <check-info> object in constraints.xml Sub element
173 <name> should match with <name> of corresponding <check-info>
174 element defined in constraints.xml.
175 -->
176 <!ELEMENT check (name, parameters?)>
177
178
179 <!--
180 This element represent, Constraint parameters.
181 Number of sub elements, <parameter> should match with the number
182 of <argument> sub elements, of corresponding <arguments> element
183 in constraints.xml
184 -->
185 <!ELEMENT parameters (parameter+)>
186
187
188 <!--
189 This element represents, a Constraint parameter.
190 Sub elements <name> should match with the <name> sub element of
191 corresponding <argument> element in constraints.xml
192 <value> could be one or more. In case of an variable array
193 argument, multiple <value> elements will be used.
194 Example : InConstraint
195 -->
196 <!ELEMENT parameter (name, value+)>
197
198
199 <!--
200 Used in elements : <element>, <check> and <parameter>
201 In <element> , it represents the name(xpath - complete absolute
202 name of an element(leaf).
203 In <check> , it represents name of a Constraint. This is the
204 linking element for <check> element in validation.xml and
205 <check-info> element in constraints.xml.
206 In <parameter>, it represents name of parameter. This is the
207 linking element for <parameter> element in validation.xml and
208 <argument> element in constraints.xml.
209 -->
210 <!ELEMENT name (#PCDATA)>
211
212
213 <!--
214 This element represents the value of a parameter.
215 -->
216 <!ELEMENT value (#PCDATA)>
217
218 */

219
Popular Tags