KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

262
Popular Tags