Beispiel #1
0
 /**
  * Removes the given top level ComplexType from this Schema
  *
  * @param complexType the ComplexType to remove
  * @return true if the complexType has been removed, or false if the complexType wasn't top level
  *     or didn't exist in this Schema
  */
 public boolean removeComplexType(ComplexType complexType) {
   if (complexType.isTopLevel()) {
     if (complexTypes.contains(complexType)) {
       complexTypes.remove(complexType.getName());
       return true;
     }
   }
   return false;
 } // -- removeComplexType
Beispiel #2
0
 /**
  * Sets the base type for this ComplexType
  *
  * @param baseType the base type which this ComplexType extends or restricts
  */
 public void setBaseType(XMLType baseType) {
   super.setBaseType(baseType);
   if (baseType != null) {
     if (baseType.isSimpleType()) {
       _complexContent = false;
       _content = new SimpleContent((SimpleType) baseType);
     } else if (baseType.isComplexType()) {
       ComplexType complexType = (ComplexType) baseType;
       if (complexType.isSimpleContent()) {
         _complexContent = false;
         _content = ((SimpleContent) complexType.getContentType()).copy();
       } else _complexContent = true;
     } else {
       // -- assuming anyType
       _complexContent = true;
     }
   }
 } // -- setBaseType
Beispiel #3
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