KickJava   Java API By Example, From Geeks To Geeks.

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


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 Parameter matches the schema element parameter
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 Parameter 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 VALUE = "Value"; // NOI18N
41

42     public Parameter() {
43         this(Common.USE_DEFAULT_VALUES);
44     }
45
46     public Parameter(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("value", // NOI18N
55
VALUE,
56             Common.TYPE_1_N | 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 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 containing at least one element
78
public void setValue(int index, String JavaDoc value) {
79         this.setValue(VALUE, index, value);
80     }
81
82     //
83
public String JavaDoc getValue(int index) {
84         return (String JavaDoc)this.getValue(VALUE, index);
85     }
86
87     // This attribute is an array containing at least one element
88
public void setValue(String JavaDoc[] value) {
89         this.setValue(VALUE, value);
90     }
91
92     //
93
public String JavaDoc[] getValue() {
94         return (String JavaDoc[])this.getValues(VALUE);
95     }
96
97     // Return the number of properties
98
public int sizeValue() {
99         return this.size(VALUE);
100     }
101
102     // Add a new element returning its index in the list
103
public int addValue(String JavaDoc value) {
104         return this.addValue(VALUE, 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 removeValue(String JavaDoc value) {
112         return this.removeValue(VALUE, 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 value
131
if (sizeValue() == 0) {
132             throw new org.netbeans.modules.schema2beans.ValidateException("sizeValue() == 0", "value", this); // NOI18N
133
}
134         for (int _index = 0; _index < sizeValue(); ++_index) {
135             String JavaDoc element = getValue(_index);
136             if (element != null) {
137             }
138         }
139     }
140
141     // Dump the content of this bean returning it as a String
142
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
143         String JavaDoc s;
144         Object JavaDoc o;
145         org.netbeans.modules.schema2beans.BaseBean n;
146         str.append(indent);
147         str.append("Name"); // NOI18N
148
str.append(indent+"\t"); // NOI18N
149
str.append("<"); // NOI18N
150
s = this.getName();
151         str.append((s==null?"null":s.trim())); // NOI18N
152
str.append(">\n"); // NOI18N
153
this.dumpAttributes(NAME, 0, str, indent);
154
155         str.append(indent);
156         str.append("Value["+this.sizeValue()+"]"); // NOI18N
157
for(int i=0; i<this.sizeValue(); i++)
158         {
159             str.append(indent+"\t");
160             str.append("#"+i+":");
161             str.append(indent+"\t"); // NOI18N
162
str.append("<"); // NOI18N
163
s = this.getValue(i);
164             str.append((s==null?"null":s.trim())); // NOI18N
165
str.append(">\n"); // NOI18N
166
this.dumpAttributes(VALUE, i, str, indent);
167         }
168
169     }
170     public String JavaDoc dumpBeanNode(){
171         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
172         str.append("Parameter\n"); // NOI18N
173
this.dump(str, "\n "); // NOI18N
174
return str.toString();
175     }}
176
177 // END_NOI18N
178

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

257
Popular Tags