KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.netbeans.modules.j2ee.sun.validation.constraints.data;
21
22 import org.w3c.dom.*;
23 import org.netbeans.modules.schema2beans.*;
24 import java.beans.*;
25 import java.util.*;
26
27 // BEGIN_NOI18N
28

29 public class CheckInfo extends org.netbeans.modules.schema2beans.BaseBean
30 {
31
32     static Vector comparators = new Vector();
33
34     static public final String JavaDoc NAME = "Name"; // NOI18N
35
static public final String JavaDoc CLASSNAME = "Classname"; // NOI18N
36
static public final String JavaDoc ARGUMENTS = "Arguments"; // NOI18N
37

38     public CheckInfo() {
39         this(Common.USE_DEFAULT_VALUES);
40     }
41
42     public CheckInfo(int options)
43     {
44         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
45         // Properties (see root bean comments for the bean graph)
46
this.createProperty("name", // NOI18N
47
NAME,
48             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
49             String JavaDoc.class);
50         this.createProperty("classname", // NOI18N
51
CLASSNAME,
52             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
53             String JavaDoc.class);
54         this.createProperty("arguments", // NOI18N
55
ARGUMENTS,
56             Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY,
57             Arguments.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 mandatory
78
public void setClassname(String JavaDoc value) {
79         this.setValue(CLASSNAME, value);
80     }
81
82     //
83
public String JavaDoc getClassname() {
84         return (String JavaDoc)this.getValue(CLASSNAME);
85     }
86
87     // This attribute is optional
88
public void setArguments(Arguments value) {
89         this.setValue(ARGUMENTS, value);
90     }
91
92     //
93
public Arguments getArguments() {
94         return (Arguments)this.getValue(ARGUMENTS);
95     }
96
97     //
98
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
99         comparators.add(c);
100     }
101
102     //
103
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
104         comparators.remove(c);
105     }
106     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
107         boolean restrictionFailure = false;
108         // Validating property name
109
if (getName() == null) {
110             throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); // NOI18N
111
}
112         // Validating property classname
113
if (getClassname() == null) {
114             throw new org.netbeans.modules.schema2beans.ValidateException("getClassname() == null", "classname", this); // NOI18N
115
}
116         // Validating property arguments
117
if (getArguments() != null) {
118             getArguments().validate();
119         }
120     }
121
122     // Dump the content of this bean returning it as a String
123
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
124         String JavaDoc s;
125         Object JavaDoc o;
126         org.netbeans.modules.schema2beans.BaseBean n;
127         str.append(indent);
128         str.append("Name"); // NOI18N
129
str.append(indent+"\t"); // NOI18N
130
str.append("<"); // NOI18N
131
s = this.getName();
132         str.append((s==null?"null":s.trim())); // NOI18N
133
str.append(">\n"); // NOI18N
134
this.dumpAttributes(NAME, 0, str, indent);
135
136         str.append(indent);
137         str.append("Classname"); // NOI18N
138
str.append(indent+"\t"); // NOI18N
139
str.append("<"); // NOI18N
140
s = this.getClassname();
141         str.append((s==null?"null":s.trim())); // NOI18N
142
str.append(">\n"); // NOI18N
143
this.dumpAttributes(CLASSNAME, 0, str, indent);
144
145         str.append(indent);
146         str.append("Arguments"); // NOI18N
147
n = (org.netbeans.modules.schema2beans.BaseBean) this.getArguments();
148         if (n != null)
149             n.dump(str, indent + "\t"); // NOI18N
150
else
151             str.append(indent+"\tnull"); // NOI18N
152
this.dumpAttributes(ARGUMENTS, 0, str, indent);
153
154     }
155     public String JavaDoc dumpBeanNode(){
156         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
157         str.append("CheckInfo\n"); // NOI18N
158
this.dump(str, "\n "); // NOI18N
159
return str.toString();
160     }}
161
162 // END_NOI18N
163

164
165 /*
166         The following schema file has been used for generation:
167
168 <!--
169   XML DTD for for constraints xml.
170   constraints.xml is used to specify provide information of the
171   Constraints to the Validation framework.
172  
173   $Revision: 1.2 $
174 -->
175
176
177 <!--
178 This is the root element.
179 -->
180 <!ELEMENT constraints (check-info*)>
181
182
183 <!--
184 This represents an information, about a particular Constraint.
185 Provides information of a Constraint represented by corresponding
186 <check> element in validation.xml.
187 Sub element <name> is used to link this element with the
188 corresponding <check> element in validation.xml.
189 -->
190 <!ELEMENT check-info (name, classname, arguments?)>
191
192
193 <!--
194 This element represents information of a Constraint class arguments.
195 Number of sub elements, <argument> should match with the number
196 of <parameter> sub elements, of corresponding <arguments> element
197 in validation.xml
198 -->
199 <!ELEMENT arguments (argument+)>
200
201
202 <!--
203 This element represents information of a single Constraint class
204 argument.
205 Sub elements <name> should match with the <name> sub element of
206 corresponding <parameter> element in constraints.xml
207 -->
208 <!ELEMENT argument (name, type?)>
209
210
211 <!--
212 Used in two elements <check-info> and <argument>
213 In <check-info>, it represents a Constraint name and is the linking
214 element between <check> element in validation.xml and <check-info>
215 element in constraints.xml.
216 In <argument>, it represents argument name and is the linking element
217 between <parameter> element in validation.xml and <argument> element
218 in constraints.xml.
219 -->
220 <!ELEMENT name (#PCDATA)>
221
222
223 <!--
224 This element represents Constraint class name.
225 Constraint class should provide the constructor with no arguments.
226 Constraint class should also provide the set* methods for all the
227 required arguments.
228 Constraint class is always created using default constructor and
229 then the arguments are set using set* methods.
230 -->
231 <!ELEMENT classname (#PCDATA)>
232
233
234 <!--
235 This element represents the type of an argument.
236 If not specified, it defaults to java.lang.String
237 -->
238 <!ELEMENT type (#PCDATA)>
239
240 */

241
Popular Tags