001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /**
043: * This generated bean class Parameters matches the schema element parameters
044: *
045: */package org.netbeans.modules.j2ee.sun.validation.data;
046:
047: import org.w3c.dom.*;
048: import org.netbeans.modules.schema2beans.*;
049: import java.beans.*;
050: import java.util.*;
051:
052: // BEGIN_NOI18N
053:
054: public class Parameters extends
055: org.netbeans.modules.schema2beans.BaseBean {
056:
057: static Vector comparators = new Vector();
058:
059: static public final String PARAMETER = "Parameter"; // NOI18N
060:
061: public Parameters() {
062: this (Common.USE_DEFAULT_VALUES);
063: }
064:
065: public Parameters(int options) {
066: super (comparators,
067: new org.netbeans.modules.schema2beans.Version(1, 2, 0));
068: // Properties (see root bean comments for the bean graph)
069: this .createProperty("parameter", // NOI18N
070: PARAMETER, Common.TYPE_1_N | Common.TYPE_BEAN
071: | Common.TYPE_KEY, Parameter.class);
072: this .initialize(options);
073: }
074:
075: // Setting the default values of the properties
076: void initialize(int options) {
077:
078: }
079:
080: // This attribute is an array containing at least one element
081: public void setParameter(int index, Parameter value) {
082: this .setValue(PARAMETER, index, value);
083: }
084:
085: //
086: public Parameter getParameter(int index) {
087: return (Parameter) this .getValue(PARAMETER, index);
088: }
089:
090: // This attribute is an array containing at least one element
091: public void setParameter(Parameter[] value) {
092: this .setValue(PARAMETER, value);
093: }
094:
095: //
096: public Parameter[] getParameter() {
097: return (Parameter[]) this .getValues(PARAMETER);
098: }
099:
100: // Return the number of properties
101: public int sizeParameter() {
102: return this .size(PARAMETER);
103: }
104:
105: // Add a new element returning its index in the list
106: public int addParameter(
107: org.netbeans.modules.j2ee.sun.validation.data.Parameter value) {
108: return this .addValue(PARAMETER, value);
109: }
110:
111: //
112: // Remove an element using its reference
113: // Returns the index the element had in the list
114: //
115: public int removeParameter(
116: org.netbeans.modules.j2ee.sun.validation.data.Parameter value) {
117: return this .removeValue(PARAMETER, value);
118: }
119:
120: //
121: public static void addComparator(
122: org.netbeans.modules.schema2beans.BeanComparator c) {
123: comparators.add(c);
124: }
125:
126: //
127: public static void removeComparator(
128: org.netbeans.modules.schema2beans.BeanComparator c) {
129: comparators.remove(c);
130: }
131:
132: public void validate()
133: throws org.netbeans.modules.schema2beans.ValidateException {
134: boolean restrictionFailure = false;
135: // Validating property parameter
136: if (sizeParameter() == 0) {
137: throw new org.netbeans.modules.schema2beans.ValidateException(
138: "sizeParameter() == 0", "parameter", this ); // NOI18N
139: }
140: for (int _index = 0; _index < sizeParameter(); ++_index) {
141: org.netbeans.modules.j2ee.sun.validation.data.Parameter element = getParameter(_index);
142: if (element != null) {
143: element.validate();
144: }
145: }
146: }
147:
148: // Dump the content of this bean returning it as a String
149: public void dump(StringBuffer str, String indent) {
150: String s;
151: Object o;
152: org.netbeans.modules.schema2beans.BaseBean n;
153: str.append(indent);
154: str.append("Parameter[" + this .sizeParameter() + "]"); // NOI18N
155: for (int i = 0; i < this .sizeParameter(); i++) {
156: str.append(indent + "\t");
157: str.append("#" + i + ":");
158: n = (org.netbeans.modules.schema2beans.BaseBean) this
159: .getParameter(i);
160: if (n != null)
161: n.dump(str, indent + "\t"); // NOI18N
162: else
163: str.append(indent + "\tnull"); // NOI18N
164: this .dumpAttributes(PARAMETER, i, str, indent);
165: }
166:
167: }
168:
169: public String dumpBeanNode() {
170: StringBuffer str = new StringBuffer();
171: str.append("Parameters\n"); // NOI18N
172: this .dump(str, "\n "); // NOI18N
173: return str.toString();
174: }
175: }
176:
177: // END_NOI18N
178:
179: /*
180: The following schema file has been used for generation:
181:
182: <!--
183: XML DTD for for validation xml.
184: validation.xml is used to specify Constraints to be applied to
185: elements.
186:
187: $Revision$
188: -->
189:
190:
191: <!--
192: This is the root element
193: -->
194: <!ELEMENT validation (element*) >
195: <!ATTLIST validation
196: validate CDATA (true | false) "true">
197:
198:
199: <!--
200: This element represents, the set of Constraints to be applied to
201: the given element.
202: -->
203: <!ELEMENT element (name, check*)>
204:
205:
206: <!--
207: This element represents, a particular Constraint.
208: Note : Information about this Constraint must be provided through
209: corresponding <check-info> object in constraints.xml Sub element
210: <name> should match with <name> of corresponding <check-info>
211: element defined in constraints.xml.
212: -->
213: <!ELEMENT check (name, parameters?)>
214:
215:
216: <!--
217: This element represent, Constraint parameters.
218: Number of sub elements, <parameter> should match with the number
219: of <argument> sub elements, of corresponding <arguments> element
220: in constraints.xml
221: -->
222: <!ELEMENT parameters (parameter+)>
223:
224:
225: <!--
226: This element represents, a Constraint parameter.
227: Sub elements <name> should match with the <name> sub element of
228: corresponding <argument> element in constraints.xml
229: <value> could be one or more. In case of an variable array
230: argument, multiple <value> elements will be used.
231: Example : InConstraint
232: -->
233: <!ELEMENT parameter (name, value+)>
234:
235:
236: <!--
237: Used in elements : <element>, <check> and <parameter>
238: In <element> , it represents the name(xpath - complete absolute
239: name of an element(leaf).
240: In <check> , it represents name of a Constraint. This is the
241: linking element for <check> element in validation.xml and
242: <check-info> element in constraints.xml.
243: In <parameter>, it represents name of parameter. This is the
244: linking element for <parameter> element in validation.xml and
245: <argument> element in constraints.xml.
246: -->
247: <!ELEMENT name (#PCDATA)>
248:
249:
250: <!--
251: This element represents the value of a parameter.
252: -->
253: <!ELEMENT value (#PCDATA)>
254:
255: */
|