:  » IDE-Netbeans » j2ee » org » netbeans » modules » j2ee » sun » validation » constraints » data » Java Open Source

Java Open Source » IDE Netbeans » j2ee 
j2ee » org » netbeans » modules » j2ee » sun » validation » constraints » data »
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common
 * Development and Distribution License("CDDL") (collectively, the
 * "License"). You may not use this file except in compliance with the
 * License. You can obtain a copy of the License at
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
 * specific language governing permissions and limitations under the
 * License.  When distributing the software, include this License Header
 * Notice in each file and include the License file at
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the GPL Version 2 section of the License file that
 * accompanied this code. If applicable, add the following below the
 * License Header, with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 * Contributor(s):
 * The Original Software is NetBeans. The Initial Developer of the Original
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
 * Microsystems, Inc. All Rights Reserved.
 * If you wish your version of this file to be governed by only the CDDL
 * or only the GPL Version 2, indicate your decision by adding
 * "[Contributor] elects to include this software in this distribution
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
 * single choice of license, a recipient has the option to distribute
 * your version of this file under either the CDDL, the GPL Version 2 or
 * to extend the choice of license to its licensees as provided above.
 * However, if you add GPL Version 2 code and therefore, elected the GPL
 * Version 2 license, then the option applies only if the new code is
 * made subject to such option by the copyright holder.


import org.w3c.dom.*;
import org.netbeans.modules.schema2beans.*;
import java.beans.*;
import java.util.*;


public class Argument extends org.netbeans.modules.schema2beans.BaseBean

  static Vector comparators = new Vector();

  static public final String NAME = "Name";  // NOI18N
  static public final String TYPE = "Type";  // NOI18N

  public Argument() {

  public Argument(int options)
    super(comparators, new org.netbeans.modules.schema2beans.Version(1, 2, 0));
    // Properties (see root bean comments for the bean graph)
    this.createProperty("name",   // NOI18N
      Common.TYPE_1 | Common.TYPE_STRING | Common.TYPE_KEY, 
    this.createProperty("type",   // NOI18N
      Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 

  // Setting the default values of the properties
  void initialize(int options)

  // This attribute is mandatory
  public void setName(String value) {
    this.setValue(NAME, value);

  public String getName() {
    return (String)this.getValue(NAME);

  // This attribute is optional
  public void setType(String value) {
    this.setValue(TYPE, value);

  public String getType() {
    return (String)this.getValue(TYPE);

  public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {

  public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
  public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
    boolean restrictionFailure = false;
    // Validating property name
    if (getName() == null) {
      throw new org.netbeans.modules.schema2beans.ValidateException("getName() == null", "name", this);  // NOI18N
    // Validating property type
    if (getType() != null) {

  // Dump the content of this bean returning it as a String
  public void dump(StringBuffer str, String indent){
    String s;
    Object o;
    org.netbeans.modules.schema2beans.BaseBean n;
    str.append("Name");  // NOI18N
    str.append(indent+"\t");  // NOI18N
    str.append("<");  // NOI18N
    s = this.getName();
    str.append((s==null?"null":s.trim()));  // NOI18N
    str.append(">\n");  // NOI18N
    this.dumpAttributes(NAME, 0, str, indent);

    str.append("Type");  // NOI18N
    str.append(indent+"\t");  // NOI18N
    str.append("<");  // NOI18N
    s = this.getType();
    str.append((s==null?"null":s.trim()));  // NOI18N
    str.append(">\n");  // NOI18N
    this.dumpAttributes(TYPE, 0, str, indent);

  public String dumpBeanNode(){
    StringBuffer str = new StringBuffer();
    str.append("Argument\n");  // NOI18N
    this.dump(str, "\n  ");  // NOI18N
    return str.toString();


    The following schema file has been used for generation:

  XML DTD for for constraints xml.
  constraints.xml is used to specify provide information of the
  Constraints to the Validation framework.

This is the root element.
<!ELEMENT constraints (check-info*)>

This represents an information, about a particular Constraint.
Provides information of a Constraint represented by corresponding
<check> element in validation.xml.
Sub element <name> is used to link this element with the
corresponding <check> element in validation.xml.
<!ELEMENT check-info (name, classname, arguments?)>

This element represents information of a Constraint class arguments.
Number of sub elements, <argument> should match with the number
of <parameter> sub elements, of corresponding <arguments> element
in validation.xml
<!ELEMENT arguments (argument+)>

This element represents information of a single Constraint class
Sub elements <name> should match with the <name> sub element of
corresponding <parameter> element in constraints.xml
<!ELEMENT argument (name, type?)>

Used in two elements <check-info> and <argument>
In <check-info>, it represents a Constraint name and is the linking
element between <check> element in validation.xml and <check-info>
element in constraints.xml.
In <argument>, it represents argument name and is the linking element
between <parameter> element in validation.xml and <argument> element
in constraints.xml.

This element represents Constraint class name.
Constraint class should provide the constructor with no arguments.
Constraint class should also provide the set* methods for all the
required arguments.
Constraint class is always created using default constructor and
then the arguments are set using set* methods.
<!ELEMENT classname (#PCDATA)>

This element represents the type of an argument.
If not specified, it defaults to java.lang.String

*/  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.