KickJava   Java API By Example, From Geeks To Geeks.

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


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 Argument 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 TYPE = "Type"; // NOI18N
36

37     public Argument() {
38         this(Common.USE_DEFAULT_VALUES);
39     }
40
41     public Argument(int options)
42     {
43         super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
44         // Properties (see root bean comments for the bean graph)
45
this.createProperty("name", // NOI18N
46
NAME,
47             Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY,
48             String JavaDoc.class);
49         this.createProperty("type", // NOI18N
50
TYPE,
51             Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY,
52             String JavaDoc.class);
53         this.initialize(options);
54     }
55
56     // Setting the default values of the properties
57
void initialize(int options)
58     {
59         
60     }
61
62     // This attribute is mandatory
63
public void setName(String JavaDoc value) {
64         this.setValue(NAME, value);
65     }
66
67     //
68
public String JavaDoc getName() {
69         return (String JavaDoc)this.getValue(NAME);
70     }
71
72     // This attribute is optional
73
public void setType(String JavaDoc value) {
74         this.setValue(TYPE, value);
75     }
76
77     //
78
public String JavaDoc getType() {
79         return (String JavaDoc)this.getValue(TYPE);
80     }
81
82     //
83
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
84         comparators.add(c);
85     }
86
87     //
88
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
89         comparators.remove(c);
90     }
91     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
92         boolean restrictionFailure = false;
93         // Validating property name
94
if (getName() == null) {
95             throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this); // NOI18N
96
}
97         // Validating property type
98
if (getType() != null) {
99         }
100     }
101
102     // Dump the content of this bean returning it as a String
103
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
104         String JavaDoc s;
105         Object JavaDoc o;
106         org.netbeans.modules.schema2beans.BaseBean n;
107         str.append(indent);
108         str.append("Name"); // NOI18N
109
str.append(indent+"\t"); // NOI18N
110
str.append("<"); // NOI18N
111
s = this.getName();
112         str.append((s==null?"null":s.trim())); // NOI18N
113
str.append(">\n"); // NOI18N
114
this.dumpAttributes(NAME, 0, str, indent);
115
116         str.append(indent);
117         str.append("Type"); // NOI18N
118
str.append(indent+"\t"); // NOI18N
119
str.append("<"); // NOI18N
120
s = this.getType();
121         str.append((s==null?"null":s.trim())); // NOI18N
122
str.append(">\n"); // NOI18N
123
this.dumpAttributes(TYPE, 0, str, indent);
124
125     }
126     public String JavaDoc dumpBeanNode(){
127         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
128         str.append("Argument\n"); // NOI18N
129
this.dump(str, "\n "); // NOI18N
130
return str.toString();
131     }}
132
133 // END_NOI18N
134

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

212
Popular Tags