示例#1
0
  /**
   * Adds the given Complextype definition to this Schema defintion
   *
   * @param complextype the Complextype to add to this Schema
   * @exception SchemaException if the Complextype does not have a name or if another Complextype
   *     already exists with the same name
   */
  public synchronized void addComplexType(ComplexType complexType) throws SchemaException {

    String name = complexType.getName();

    if (name == null) {
      String err = "a global ComplexType must contain a name.";
      throw new SchemaException(err);
    }
    if (complexType.getSchema() != this) {
      String err = "invalid attempt to add an ComplexType which ";
      err += "belongs to a different Schema; type name: " + name;
      throw new SchemaException(err);
    }
    if (complexTypes.get(name) != null) {
      String err = "a ComplexType already exists with the given name: ";
      throw new SchemaException(err + name);
    }
    complexTypes.put(name, complexType);
  } // -- addComplextype