KickJava   Java API By Example, From Geeks To Geeks.

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


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 Arguments extends org.netbeans.modules.schema2beans.BaseBean
30 {
31
32     static Vector comparators = new Vector();
33
34     static public final String JavaDoc ARGUMENT = "Argument"; // NOI18N
35

36     public Arguments() {
37         this(Common.USE_DEFAULT_VALUES);
38     }
39
40     public Arguments(int options)
41     {
42         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
43         // Properties (see root bean comments for the bean graph)
44
this.createProperty("argument", // NOI18N
45
ARGUMENT,
46             Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY,
47             Argument.class);
48         this.initialize(options);
49     }
50
51     // Setting the default values of the properties
52
void initialize(int options)
53     {
54
55     }
56
57     // This attribute is an array containing at least one element
58
public void setArgument(int index, Argument value) {
59         this.setValue(ARGUMENT, index, value);
60     }
61
62     //
63
public Argument getArgument(int index) {
64         return (Argument)this.getValue(ARGUMENT, index);
65     }
66
67     // This attribute is an array containing at least one element
68
public void setArgument(Argument[] value) {
69         this.setValue(ARGUMENT, value);
70     }
71
72     //
73
public Argument[] getArgument() {
74         return (Argument[])this.getValues(ARGUMENT);
75     }
76
77     // Return the number of properties
78
public int sizeArgument() {
79         return this.size(ARGUMENT);
80     }
81
82     // Add a new element returning its index in the list
83
public int addArgument(org.netbeans.modules.j2ee.sun.validation.constraints.data.Argument value) {
84         return this.addValue(ARGUMENT, value);
85     }
86
87     //
88
// Remove an element using its reference
89
// Returns the index the element had in the list
90
//
91
public int removeArgument(org.netbeans.modules.j2ee.sun.validation.constraints.data.Argument value) {
92         return this.removeValue(ARGUMENT, value);
93     }
94
95     //
96
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
97         comparators.add(c);
98     }
99
100     //
101
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
102         comparators.remove(c);
103     }
104     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
105         boolean restrictionFailure = false;
106         // Validating property argument
107
if (sizeArgument() == 0) {
108             throw new org.netbeans.modules.schema2beans.ValidateException("sizeArgument() == 0", "argument", this); // NOI18N
109
}
110         for (int _index = 0; _index < sizeArgument(); ++_index) {
111             org.netbeans.modules.j2ee.sun.validation.constraints.data.Argument element = getArgument(_index);
112             if (element != null) {
113                 element.validate();
114             }
115         }
116     }
117
118     // Dump the content of this bean returning it as a String
119
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
120         String JavaDoc s;
121         Object JavaDoc o;
122         org.netbeans.modules.schema2beans.BaseBean n;
123         str.append(indent);
124         str.append("Argument["+this.sizeArgument()+"]"); // NOI18N
125
for(int i=0; i<this.sizeArgument(); i++)
126         {
127             str.append(indent+"\t");
128             str.append("#"+i+":");
129             n = (org.netbeans.modules.schema2beans.BaseBean) this.getArgument(i);
130             if (n != null)
131                 n.dump(str, indent + "\t"); // NOI18N
132
else
133                 str.append(indent+"\tnull"); // NOI18N
134
this.dumpAttributes(ARGUMENT, i, str, indent);
135         }
136
137     }
138     public String JavaDoc dumpBeanNode(){
139         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
140         str.append("Arguments\n"); // NOI18N
141
this.dump(str, "\n "); // NOI18N
142
return str.toString();
143     }}
144
145 // END_NOI18N
146

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

224
Popular Tags